Compatibility with Field group module

Created on 4 September 2017, about 7 years ago
Updated 12 August 2024, 3 months ago

I suggest Commerce 2.x would work out-of-box with Field group module. Field group is in TOP10 for most installed contrib modules for Drupal8. With latest dev-version of Field group one can create hooks like this to get Field groups to be rendered in Commerce entities.

function HOOK_field_group_content_element_keys_alter(&$keys) {
  $keys['commerce_product'] = 'product';
}

Without this hook Field group does not provide any markup and is misleading if Commerce entites is created via Drupal UI (+Field group).

Feature request
Status

Fixed

Version

2.0

Component

Contributed modules

Created by

🇫🇮Finland sokru

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.

  • 🇷🇺Russia Hamulus

    @bolaghi, the guide is not usable in Field groups context

    However I could get the proper result by this preprocess code in custom module:

    function mytheme_preprocess_commerce_product(&$variables){
        
        if ($variables['elements']['#view_mode'] == 'full') {
            $variables['elements']['#fieldgroups']['group_right']->children[] = 'variation_list_price';
            $variables['elements']['#fieldgroups']['group_right']->children[] = 'variation_price';
    
            $variables['elements']['#group_children']['variation_list_price'] = 'group_right';
            $variables['elements']['#group_children']['variation_price'] = 'group_right';
        }
    }
    
  • 🇩🇪Germany geek-merlin Freiburg, Germany

    For stores, see related issue.

  • 🇬🇧United Kingdom chrisscrumping

    Been struggling with this issue today and in case its helpful to anyone else I have finally managed to get it working..... I wanted a field group for a product variation type.

    Thanks Hamulus you pointed me in the right direction!

    First I don't think its possible to use Field Groups that are created on Commerce Product Variations, you must create them on the Commerce Product.

    Once you have created the required groups use the example Hamulus provided to move variation fields into the field groups.

    Not great for a site builder but at least it works!

  • 🇩🇪Germany Anybody Porta Westfalica

    Re #48 any ideas from the Commerce maintainers / Centarro if this should be a follow-up and if there's a good way to solve that?

    Is #3121339: Widget "Single variation (Product information)" ignores field groups evantually related?

Production build 0.71.5 2024