We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How to get spend to display on product page

How to get spend to display on product page

needhelp8
Tourist
4 0 2

Is it possible to get the total spend per product on the product page? I'd like the customer to see how much they are spending on each product before adding t teh cart. I do not want the total cart amount to appear on the product page. I have 2-3 variants per product and at the moment no total appears on the product page (even if the customer is only buying a qty of 1). I am using Shopify Masonry.

 

I used this code and managed to get the text "total spent: $0" - but it didn't calculate the money and only said $0

{% assign total_spend = product.price | times: quantity %}
<p>Total Spend: {{ total_spend | money }}</p>

 

Reply 1 (1)

Guleria
Shopify Partner
4299 825 1189

Hello @needhelp8 ,

 

Yes possible but the solution will be Javascript.
The code you shared is not working because quantity is not defined. If you define the quantity then it will start working. 
e.g. 
{% assign quantity = 2 %}
{% assign total_spend = product.price | times: quantity %}
<p>Total Spend: {{ total_spend | money }}</p>

But in this way quantity will be static and total never be changed on change of the quantity. 

 

Regards

Guleria

 

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.