Using the Venture theme, I’ve updated the product-template liquid to hide the price of a product when it’s out of stock. It’s just an easy {% if variant.available %} … {% endif %}.
It works when I refresh the page with the variant, but then when I change the variant it does not get updated, though the price within gets updated.
So how do I trigger an update to that part of the DOM, so that I can hide/show price on variant change?
Thank you for your answer, though what is surprising me is that it looks like there’s an observer mechanism implemented as when I change the variant, the prices change, the image changes, the checkout button change.
But when I add some custom conditions in my theme’s code and it does not work.
I looked at the theme.js and it looks like the obverver mechanism is implemented by the Variant singleton, the updatePrice function contains:
But I’m not understanding how it’s being propagated to trigger focused DOM changes. I can hijack the onChange, but because it works elsewhere without using onChange on the select, I’m wondering how it’s being implemented in the theme.