1

I'm confused, how to display on Views just one price for product with variations? I have product with 2 variation, and both prices are displayed, like: Price: 1-Price for 1-Variation-Product , Price: 2-Price for 2-Variation-Product

I mean the created from me some custom view-page, like "/all-products" (like some catalog page) where are displayed all of products or goods with their prices. And for the products with variations I see, that there will be displayed all of prices of this product.

In the Settings of View-Page ("/all-products") I have in Format section: "Show:Fields | Settings".

In RELATIONSHIPS: Variations: Product variation

(Variations: Product variation) Product: Product

And in Fields I have: (Variations: Product variation) Product variation relationship: Price

where in the Setting I have: "Use entity field rendering"

There are no Setting to handle multiple values.

If I check out "Use entity field rendering" then will be shown some settings for handling of multiple values, but in this case it will be no price displayed on view-page (/all-products), because the prices are rendering from product entity, as I understand.

So, this is the problem

In addition: the product with variation has all the same price, not different prices for different variation.

What is teh best way to handle it?

I have Drupal 9, Commerce 2

Thanks

1
  • Very keep on achieving this this too. Did you work it out? My use case is a views page for a search api / facets-based product catalog. My add to cart is using the Variation Title widget. Commented Nov 14, 2022 at 21:27

2 Answers 2

1

I think I found a solution, in "Fields" just instead

"(Variations: Product variation) Product variation relationship: Price"

need to use:

"Product datasource: Variations", and there are some settings to handle multiple values.

In "Formatter" need to set "Rendered entry", instead default "Label"

0

It depends on how your view is configured, but here is a basic setup that will only show one price.

Create a view of Products with the Default view mode.

Then configure the Default view mode at /admin/commerce/config/product-types/MY_PRODUCT_TYPE/edit/display.

For Variations, you can change the Format to Add to cart form, which will show a dropdown for selecting the variations and the price of the current variation only. You can check out the other options too; one of them may be better for your use case.

4
  • thanks for answering, but this settings I have already and on Product page I have dropdown for selecting the variations. With my question "Display price on Views " I mean the created from me some custom view-page, like "/all-products" (like some catalog page) where are displayed all of products or goods with theyr prices. And for the products with variations I see, that there will be displayed all of prices of this product. Commented Nov 28, 2020 at 9:51
  • @lexx You need to describe exactly how you created your custom view page; what is displayed is controlled based on the settings, so without you sharing the exact settings, it is not possible to help you. Commented Nov 28, 2020 at 9:57
  • @lexx You should edit your question to include this information instead of posting it in a comment; that way, people who visit this question page will find all the information in the question. Commented Nov 28, 2020 at 10:19
  • Ok, thanks. I changed the question and delete my comments from above Commented Nov 28, 2020 at 14:35

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.