I am implementing a new feature on our page to display the price in an additional location on the product page. I am using the following code:
{%- liquid
assign current_variant = product.selected_or_first_available_variant
-%}
{{ current_variant.price | money }}
However, the current display only reflects the price of the first variant. Even after selecting other variants, the price in the new location remains unchanged.
I would greatly appreciate any assistance with this issue. Thank you in advance!
@EverGlowHair , Hope you are doing well.
Could you please share your store URL?
@EverGlowHair If it is temporarily not there then how can I check the issue?
currently, can see that price change is working on variant change.
@webwondersco
I apologize for the confusion. I have added this feature back to the page. Please check the price inside the red box; it was supposed to change, but it remains unchanged.
Hi,
You need some custom Javascript code to update price according to the variant. Can you share the full code of this feature here ? I’ll send back the Javascript code for it.
Best regards,
Thanks
@Justin-Simesy
I used the code chatgpt gave me:
{%- liquid
assign current_variant = product.selected_or_first_available_variant
-%}
{{ current_variant.price | money }}
But I don’t know where to find “actual ID of your variant selector dropdown”
Can you try to use this code
{%- liquid assign current_variant = product.selected_or_first_available_variant -%}
{{ current_variant.price | money }}
Best regards,
Justin
@Justin-Simesy
Hi Justin,
I changed it to this code, but the problem is still the same, please take a look.
Can you try again with this code
{%- liquid assign current_variant = product.selected_or_first_available_variant -%}
{{ current_variant.price | money }}
Best regards,
Justin
@Justin-Simesy
Hi Justin,
It works. Thank you very much!
1 Like
Hi Justin, I’m having the same issue, can you help me please? I’ve tried to use this same code and made some changes, but it didn’t work.