8

I have several products related to a single product display node using Drupal Commerce.

Currently this page only shows a single price (related to the product option currently selected in the dropdown). The only way you can see the prices of the other products is to change the dropdown, which invokes an AJAX request to reload the current product options (including price).

Obviously this is counter-intuitive for customers, who are used to seeing all of the prices available at one time, and not having to change to a new option with the dropdown just to see the price of that option.

How do I change this display so it functions like a traditional e-commerce website? By that I mean either a dropdown that contains the product name AND product price, or (far more preferably) a table with the list of available products, with their prices in one of the columns?

I can only assume that this very basic functionality must exist somewhere in the Commerce configuration settings somewhere, but as yet I haven't been able to find it.

I could easily write a module to code round this problem, but I'm currently evaluating Commerce to see whether it's good enough for our agency to use in future e-commerce projects, without having to re-invent the wheel over and over again. To that end, answers involving code probably won't be too useful.

Muchas gracias

4

If themeing is considered "involving code", then you could create a view block.

Using Contextual Filters and Relationships, a View will be able to list all the referenced products on a node (including their fields).

  1. Start by creating a View listing all the nodes that have a product reference field (ex: Product Display).
  2. Add a Contextual Filter for the Nid that defaults to use the Nid from the URL
  3. Next add a Relationship (Product) using the product reference field of the Product Display node
  4. Then add another Relationship (Line Item) for the Commerce Line Item of the referenced product

After that is all setup, you can add fields that use the Line Item relationship to get product titles, calculated prices, etc.

  • Brilliant, thanks! I'm new to using Views so I didn't even think of doing something like this – Clive Apr 24 '12 at 18:47
  • @Clive This mean you start using drupal views in 2012 ? – Yusef Mohamadi Jun 16 '14 at 5:12
  • @mr.moses this requires a view per product display right? I'm interested in a solution that once implemented one will be implemented on all product displays. Any ideas? – Kristoffer Rom Sep 16 '16 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.