Score:1

How do I organize the display of product variation fields?

in flag

I have a new site with Drupal 9 and Commerce 2. I am trying to display my products with:

  • Title
  • Photo
  • Price
  • Delay
  • Options
  • Add to cart button
  • Description

I tested all the possible settings in manage display, but nothing works. What I get is inconsistent with the configuration.

How do I organize the display of product variation fields?

screenshot

screenshot

screenshot

Score:1
cn flag

This is a known difficulty in Commerce 2.x. You can review the options in this issue https://www.drupal.org/project/commerce/issues/2928139

The best solution I have found is clicking show row weights in manage display for the product, the product variation, and the order item type - add to cart form - form display. You can then manually set the weights rather than drag and drop. For example set the weight of the field you want to be first to -50, and the field you want to be last to be 50. Then adjust the fields in the middle.

You will have to jump back and forth between the 3 displays I mentioned, and this won't fix all your problems, but it will help.

You can overwrite the twig template in your theme as seen here: https://www.drupal.org/project/commerce/issues/2928139#comment-13444854

You could also hack and hide all the fields, and build custom view of fields, and use display suite to add the block view to your product display.

It really depends on what exactly you want to do.

steevee666 avatar
in flag
Thanks, but I don't understand what to do with the weight of the fields
tonytheferg avatar
cn flag
Click show row weights and set the weights manually. See the issue I shared.
tonytheferg avatar
cn flag
I edited the answer with better details.
hockey2112 avatar
tr flag
The only problem with using Views is that the price doesn't update when you select the product attribute options. Unless I am doing something wrong...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.