Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
We need to display a different price for customers with a specific customer tag. This is only to DISPLAY specific prices (there is no purchase capability on the site).
I was able to do this successfully with Liquid in the product-price.liquid file, and in the product-template.liquid file:
{% if customer.tags contains 'retail' %}
{{ current_variant.price | times: 2.5 | money }}
{% else %}
{{ current_variant.price | money }}
{% endif %}
However I'm running into a wall with Javascript. The issue is when the variant changes, it loads the updatePrice JS function which reverts the price shown back to the original price.
I added a new customer metafield called "retail" and I was trying to call it within the updatePrice function:
_updatePrice: function(evt) {
var variant = evt.variant;
var customer_type = customer.metafields.custom.retail.value;
if (customer_type == "retail") {
variant.price = variant.price * 2.5;
}
However it seems that any code I add to the updatePrice function causes the site to break, menu dropdowns no longer work, etc.
Not sure why this is happening, can someone help?
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025