How to update the price of the variable "product.price | divided_by" See screenshots

Solved
Tourist
4 0 1
Hello everyone, I put in my product page a code to divide the total value of the product by 6x See here -> http://prntscr.com/o6qscy But I have two variants in size that also change the price of the product. When I change the product size the value of the code variable that divided the price by 6 is not updated. See -> http://prntscr.com/o6qsx1 I'm using the code http://prntscr.com/o6qwub
0 Likes

You need to update/toggle the price using a javascript function (onVariantChange) . Which theme are you using right now? possible to share product.liquid or product-template.liquid ?

Refer https://community.shopify.com/c/Shopify-Design/Function-to-trigger-a-variant-selection-change/td-p/2... and you will get the idea.

 

 

 

Available for hiring. Inbox me lixonic[at]gmail[dot]com
0 Likes
Tourist
4 0 1
Hi @Lixon_Louis First of all I would like to thank you for the help. The theme I'm using is Brooklyn I'm editing the file "product-template.liquid" See here -> http://prntscr.com/o6rj62 Would you have any code to insert there? Or the answer lies in the link you gave me?
0 Likes

Success.

On second thoughts, there is an easy way out. Fair Warning:  This may not work with your theme code, so backup your theme.js.liquid first. I tried this on my dev store using latest version of Brooklyn theme and it works! https://nichegeek.myshopify.com/products/orbit-basic-turntable

In your theme.js.liquid locate line no 590.  Add two lines of code to the _updateMasterSelect function as follows. The result will be like https://take.ms/NrXAJ

 

var divPrice = (variant.price/6)
$('#div-price').html(theme.Currency.formatMoney(divPrice, theme.strings.moneyFormat ))

Update the span with a new ID as marked in https://prnt.sc/o6rj62

It should like 

  <span id="div-price" style="color:red"> {{The initial liquid code}}</span> 

 

 

 

 

Available for hiring. Inbox me lixonic[at]gmail[dot]com
1 Like
Highlighted
Tourist
4 0 1
Great, I'll try ^^ Thank you my friend
0 Likes
Tourist
4 0 1
@Lixon_Louis I did it here and everything went fine, THANK YOU my friend. I will leave your contact marked here for future hiring of theme customization.
1 Like