0

I have a theme with a custom product display template. I created a product display with different product variations; when different variations are selected, the price doesn't seem to be updated to reflect the product variation chosen.

It seems to be a problem with the theme as it works with standard themes.

I tried different jQuery versions and doesn't seem to be any JavaScript error. I've read somewhere that it could be the the price not being wrapped with the appropriate classes. If that's the case, how do I fix that?

1 Answer 1

0

What you've heard is correct: Drupal Commerce adds classes around product fields that allow the Add to Cart form to target those rendered fields for replacement when attributes are selected. This is why in their absence you won't see prices updated at all.

The simplest way to illustrate it will be to simply look at the HTML on a site with a working theme and your custom theme to see what those classes look like.

The classes exist in the render arrays for these fields, so you simply need to ensure your theme is properly including the HTML element attributes for these rendered fields. Again, for that I'd simply advise you to look at working theme code to see how it's done elsewhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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