I successfully managed to display variants on my site thanks to your help.
Though, I can't seem to find a solution to updating the product price according to the selected variant.
Using the documentation I can loop through each variant price, but I'm not interested in showing all prices but rather change the one product price that is visible.
I'm wondering if that later issue is because your <input name="productIdentifier" value="" type="hidden" /> is blank when looping the variants. I think in this instance you need to give each variant an SKU and that should make them show up as individual items (IIRC).
From a visual perspective, I think you'd want to use some javascript to watch the select list for a change event then update the value on the page.
Update product price according to variant price
Umbraco: 7.11.1 Tea Commerce: 3.2.4
Hi guys,
I successfully managed to display variants on my site thanks to your help.
Though, I can't seem to find a solution to updating the product price according to the selected variant.
Using the documentation I can loop through each variant price, but I'm not interested in showing all prices but rather change the one product price that is visible.
// Mike
Hi Mike,
Do you mean just visually on the page?
Matt
Matt, you're at it again, thanks for helping me out.
It's both visually and when adding the item to the basket.
I hope that makes sense. Perhaps it isn't possible?
// Mike
Hi Mike,
I'm wondering if that later issue is because your
<input name="productIdentifier" value="" type="hidden" />
is blank when looping the variants. I think in this instance you need to give each variant an SKU and that should make them show up as individual items (IIRC).From a visual perspective, I think you'd want to use some javascript to watch the select list for a change event then update the value on the page.
You're a wizard Matt, the SKU has to be defined for it to work.
I'll do the visually representation of the prices with Javascript.
Thanks once again, Matt!
Awesome. Glad I could help.
For those who might be in a similar situation, I made a quick fix for the visual price change. It's not pretty but it's a temporary fix:
First: Display all variant prices and add a index number to each price element (using data attribute)
Next: Remove them all using CSS:
Last: Use Javascript to hide/show each price depending on the selected option index:
// Mike
Thanks for sharing this for completeness. #h5yr 🤘
is working on a reply...