Context
Many themes still contain the outdated og:price:amount
& og:price:currcency
product meta property tags.
Example Old
<meta
property="og:price:amount"
content="{{ product.price | money_without_currency | strip_html | escape }}"
>
<meta
property="og:price:currency"
content="{{ cart.currency.iso_code }}"
>
Example New
<meta
property = 'product:price:amount'
content = '{{- product.selected_or_first_available_variant.price | money_without_currency -}}'
/>
<meta
property = 'product:price:currency'
content = '{{- shop.currency -}}'
/>
As can be seen in the old example above they usually also contain
the incorrect product.price
reference instead of variant.price
.
Question
I couldn’t find why or where from the price escaping code came from.
The money_without_currency
filter returns a clean decimal value
( XX.XX
) for the price no matter the store’s currency formatting rules.
Why then did they try to strip_html
& escape
the contents?
Is it just a legacy artifact?
The only thing that money_without_currency
doesn’t account for are:
- Prices from countries where the decimal point is a comma
XX,XX
/X.XXX,XX
- Prices larger than
1000
→XX,XXX.XX
While the resulting formats might technically work , they should be normalized.
→ XXXX.XX