How to edit updatePrice in theme.js

How to edit updatePrice in theme.js

srdjank
Shopify Partner
14 0 3

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?

Replies 0 (0)