Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello guys. I have implemented custom code from this thread: click here. This added the price in the Add to cart button but removes when I select a different variant on the product page.
Does anyone know how I can fix this?
You'll need to modify that code to add an "event listener" that overwrites the "Add to cart" button's innerHTML again each time a new variant is selected.
Every theme is different, so detecting when a new variant is selected could be a challenge. However, many themes' product pages have a hidden input (named `id`) that always stores the numerical ID of the currently selected variant. You could listen to its `change` event and use the AJAX API to get the price for the currently selected variant.
(You can also use Liquid to serialize the prices of all variants as JSON to the page during rendering, so that you don't have to call the AJAX API each time)
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024