Forum

Thread tagged as: Question, Shop

Display price without currency symbol

Hi,

I am adding my Shop data to Google Shopping, and need to use the price without currency code for one of the pieces of Schema information. I currently have this as part of my product detail template:

<meta itemprop="priceCurrency" content="GBP" />
<meta itemprop="price" content="<perch:shop id="price" type="shop_currency_value"/>" />

But that is outputting £115 for the price, rather than 115. Is there a way of accessing the value of the GBP price without the symbol in the template?

Thanks!

Mike

Mike Harrison

Mike Harrison 37 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There should be. What does <perch:showall /> give you?

In showall there is an array for price and an array for current_price, both look like this:

array
(
    [47] => 115
    [44] => 170
    [142] => 
)

But not sure how I can access these in my product_detail.html template

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which page function are you using?

Pretty standard:

  perch_shop_product(perch_get('product'), [
    'template' => 'products/product_detail.html'
]);
Drew McLellan

Drew McLellan 2638 points
Perch Support

At the moment that will always return the formatted version. I'll see if we can add an option, but in the mean time, can you replace the currency symbol out?

Ah ok so

<perch:shop id="price" type="shop_currency_value" replace="£|"/>

I will give it a go tomorrow and see how it goes

Hi Drew,

That worked thanks!