Show shipping profile in checkout flow always as inline form

Created on 31 May 2021, about 3 years ago
Updated 8 April 2024, 3 months ago

Hi!

I just configured a Drupal Commerce 2 shop with Commerce Shipping. Every user can only have one profile. Now during the checkout process an existing user profile is rendered as a preview with and edit-button

After clicking the edit button I get the profile as an inline form

What I'm trying to implement now is to show the inline form of the profile right at the start, so that the user doesn't have to click on the edit button first. I'm really lost here and would appreciate any help.

EDIT:
As far as I've seen it is decided in the protected function shouldRender in Drupal\commerce_order\Plugin\Commerce\InlineForm\CustomerProfile. If the return value there is FALSE, the inline form get's rendered.

πŸ’¬ Support request
Status

Closed: works as designed

Version

2.0

Component

Miscellaneous

Created by

πŸ‡©πŸ‡ͺGermany Belshi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine r_cheh

    I found a custom solution: you need to override CustomerProfile plugin method - shouldRender, so I created CustomCustomerProfile plugin:

    class CustomCustomerProfile extends CustomerProfile {
    
      /**
       * {@inheritDoc}
       */
      protected function shouldRender(array $inline_form, FormStateInterface $form_state) {
        $render = parent::shouldRender($inline_form, $form_state);
        // Do not render inline form on shipping.
        if ($inline_form['#profile_scope'] === 'shipping') {
          return FALSE;
        }
        return $render;
      }
    }
    

    return FALSE if you want to get inline form.
    And then override plugin's class:

    function custom_module_commerce_inline_form_info_alter(array &$inline_form) {
      if (isset($inline_form['customer_profile'])) {
        $inline_form['customer_profile']['class'] = 'Drupal\custom_module\Plugin\Commerce\InlineForm\CustomCustomerProfile';
      }
    }
    
  • Status changed to Closed: works as designed 3 months ago
  • πŸ‡¦πŸ‡ΊAustralia jannakha Brisbane!

    +1 for #5 comment!
    thanks for the tip!

Production build 0.69.0 2024