Must reload product page after changing variant

Hi, I would like to assemble a text per variant depending on tags and stock. The code only works when loading the page, but not when changing the variants.

{% assign current_variant = product.selected_or_first_available_variant %}
{% if current_variant.inventory_quantity > 0 %}
 ... {{ current_variant.inventory_quantity }} ...
{% endif %}

How can I force the page to reload when changing the variant or how do I have to rewrite liquid? It also works somehow with the price.

After hours of searching .. this is my simple solution in the global.js

renderProductInfo() {
...
const destinationMYpart = document.getElementById(`mypart-${this.dataset.section}`);
const sourceMYpart = html.getElementById(`mypart-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`);
        
if (sourceMYpart && destinationMYpart) destinationMYpart.innerHTML = sourceMYpart.innerHTML;
...

where you can replace the “mypart” with your name.

Hey @hennott

Well done in finding a great solution which might help others here in the community too!