Forum

Thread tagged as: Question, Shop

Unformatted price for product.html

I have my currency decimal place formatting to be 2 decimal places because I need to properly add tax in fractional dollars in my cart.
However, on product.html I would like to display whole numbers to the user. The attribute type="shop_currency_value" seems to be preventing me from doing so. shop_currency_value is using my default 2 decimal places, and I have been unable to add format="" to override it.
Any attempt at formatting just returns zeros.
Is there a way to grab an unformatted price in product.html?

Thank you!

Olympia Kyriakides

Olympia Kyriakides 1 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think nearly every total has a formatted and unformatted version. Have you checked <perch:showall> ?

Hi Drew, thank you.

<perch:showall> does return the price unformatted, no decimals, as I've entered it, and the available id's are price perch_price and current_price.
None of these work with money formats i.e. format="$:%.2n" -- they return only zeros, not even a dollar sign.
If I remove type="shop_currency_value", the price will display in my desired format, but it will not flow through to the cart.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the full template tag you’re using?

<perch:shop id="price" type="shop_currency_value" label="Price" divider-before="Pricing" size="m" min="0" step="any" format="$:%.0n" />
I've played around a lot with the format...even trying # formats vs. $

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hi Olympia,

product.html is the default edit form template. If you are using it as a display template too, I think you can do something like this:

<!--* add this first - add the suppress attribute so it doesn't output to your page *-->
<perch:shop id="price" type="shop_currency_value" label="Price"  min="0" step="any" suppress="true" />

<!--* display the unformatted price with type text *-->
<perch:shop id="price" type="text" />

Yes, I'm using it as a display template as well. Thank you very much, that's a perfect solution.