But I still have the same problem with the price and the reference that does not show up. I never succeeded in resolving this.
Commerce 2 is really very complicated.

I use "Display Suite" for displaying product pages.
I copied the file "bs-2col-stacked--commerce-product.html.twig" into the templates folder of my theme.
Here are contents :

{#
/**
 * @file
 * Bootstrap Layouts: "2 Columns (stacked)" template.
 *
 * Available layout variables:
 * - wrapper: Wrapper element for the layout container.
 * - attributes: Wrapper attributes for the layout container.
 *
 * Available region variables:
 * - top
 * - left
 * - right
 * - bottom
 *
 * Each region variable contains the following properties:
 * - wrapper: The HTML element to use to wrap this region.
 * - attributes: The HTML attributes to use on the wrapper for this region.
 * - content: The content to go inside the wrapper for this region.
 */
#}
<{{ wrapper }}{{ attributes }}>
  {{ title_suffix.contextual_links }}

  {% if top.content %}
  <{{ top.wrapper }}{{ top.attributes }}>
    {{ top.content }}
  </{{ top.wrapper }}>
  {% endif %}

  {% if left.content %}
  <{{ left.wrapper }}{{ left.attributes }}>
    {{ left.content }}
  </{{ left.wrapper }}>
  {% endif %}

  {% if right.content %}
  <{{ right.wrapper }}{{ right.attributes }}>
    {{ right.content }}
  </{{ right.wrapper }}>
  {% endif %}

  {% if bottom.content %}
  <{{ bottom.wrapper }}{{ bottom.attributes }}>
    {{ bottom.content }}
  </{{ bottom.wrapper }}>
  {% endif %}

</{{ wrapper }}>

What should I do ?

I also encounter problems with views and product variations.

It's a nightmare.

https://drupal.stackexchange.com/questions/241357/commerce-2-the-price-o...

Thank you

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zenimagine created an issue. See original summary.

zenimagine’s picture

Issue summary: View changes
bojanz’s picture

Priority: Major » Normal

Stop using Display Suite. We don't support it, and your hidden fields problem is coming from there.

zenimagine’s picture

FileSize
123.58 KB
5.42 KB
19.59 KB
175.99 KB
148.24 KB

@bojanz
I use the following modules on my product pages :
- Display Suite
- Bootstrap Layouts
They are indispensable to me.

I found a solution to display the missing fields :
- screenshot1: create a product view with the product variations fields and add a contextual filter to display the same product as the current page.
- screenshot2: create a display block of the previous ue created.
- screenshot3: add the display block following the product type display.
- screenshot4: it works, the fields are correctly displayed on my product page.
- screenshot5: PROBLEM When I change the variation of my product, the price and sku fields are not updated. I have the same problem on all my product views.

I do not use search API for the view. But it should still work, I do not understand why. I've been looking for a solution for a week, but I can not find anything.

https://drupal.stackexchange.com/questions/241357/commerce-2-the-price-o...

bojanz’s picture

Status: Active » Fixed

@zenimagine
I keep repeating in various issues: If you use Display Suite, you can't show variation fields (including the price).
Variation field injection is only performed when you use vanilla Drupal theming.
We have never claimed Display Suite compatibility.

You have been first told this 2 months ago. Nothing has changed.

zenimagine’s picture

Status: Fixed » Active

@bojanz
I understand that display suite is not compatible with commmerce 2. But in my previous comment, I use a view (without display following). Even when creating a classic view page without display, the problem is still there (change of variation does not change the price and sku).

zenimagine’s picture

@bojanz

http://docs.drupalcommerce.org/v2/product/create-a-product-catalog.html

In the documentation you show products with color variations and that's it. No problem it also works for me.

Try displaying the "price" and "reference" fields in your view.

My question is simple: when you change the variation with the drop-down button, does the "price" and "reference" field vary?

For me NO, I also do the test on simplytest.me without adding any additional module and it does not work.

Logically the "price" and the "reference" should vary, exact?

The "Created a Product Catalog" declaration is not correctly explained. You should also explain how you do not have the same product displayed several times in the view (for example, a product with three variations will appear three times in the view).

I do not speak English, but I hope my question is understood.

The catalog example should at least display the price.

https://drupal.stackexchange.com/questions/241357/commerce-2-the-price-o...

zenimagine’s picture

I tested the change in the views on a blank site with simplytest.me and it does not work.

Create a product with two variations (two different prices).

I would like to know if you arrived to update the price by changing the variation in a view ?

bojanz’s picture

Commerce has no way of magically detecting Views fields and replacing them. If you want fields to change when the variation changes, you need to show them as a part of the rendered product, just like on the product display page.

zenimagine’s picture

Status: Active » Closed (works as designed)
zenimagine’s picture

Thank you that is clearer

FiNeX’s picture

Hi, the DS compatibility is discussed here: https://www.drupal.org/project/commerce/issues/2723689