Shopify themes, liquid, logos, and UX
I have a product that is a cash donation product. i've added a custom amount variant and want the quantity box to show when the custom variant is chosen. this works but only if i manually refresh the page and most people that visit the sit e aren't going to do this. how do i get this page to refresh automatically when the variant changes, or is there a better way.
{% if product.selected_variant.id == 30370837430349 %} <div class="product-form__item product-form__quantity-selector"> <label class="product-form__quantity-label{% unless section.settings.show_variant_labels %} product-form__quantity-label--hidden{% endunless %}" for="Quantity-{{ section.id }}">{{ 'products.product.quantity' | t }}</label> <input class="product-form__quantity-input" type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1" pattern="[0-9]*"> </div> {% endif %}
this is the "if" statement and code i have used.
i'm using shopify's free narrative theme.
Solved! Go to the solution
This is an accepted solution.
Hello BVPark,
jQuery(function() { $('.single-option-selector').on('change', function(){ setTimeout(function(){ if($('[name="id"]').val() != "{{ product.selected_or_first_available_variant.id }}"){ location.reload(); } }, 1); }); });
use this script, it will reload page on variant selection.
Thanks
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024