My prices are displayed sometimes with no decimal (60), sometimes with one decimal (60.1) and sometimes correctly (60.99). It appears they’re being truncated when they’re indexed as I’m definitely passing float values with two decimals to the index.
How can I modify my template so that prices always show as proper prices?
My template for “item” set using PHP
$item_template = '
<button id="coupon-placement-{{ objectID }}" class="is-hidden is-pulled-left button yellow listicon sale-tag gift-deal" data-toggle="modal" data-target="#{{ title_for_modal }}"></button>
<picture style="overflow:hidden;max-height:300px;" id="picture-{{ objectID }}"></picture>
<p class="gift-title tight first"><strong>{{ title }}</strong></p>
<p class="why">{{#helpers.snippet}}{ "attribute": "desc", "highlightedTagName": "mark" }{{/helpers.snippet}}</p>
<p class="price tight second">\${{ price.final }}</p>
<button type="button" class="button listicon details magenta" data-toggle="modal" data-target="#{{ title_for_modal }}" id="{{ title_for_modal }}-button">Details</button>
<a href="https://wineclubreviews.net/clicks/outbound/gi/{{ objectID }}" target="_blank" rel="nofollow noopener" id="BuyGift:{{ objectID }}" class="button listicon cart green"> Buy</a>
<ul class="three-col keywords" id="keywords-{{ objectID }}"></ul>
';
My code which sets the price value at indexing time
'price' => [
'final' => (float) number_format($final_price,2),
'regular' => (float) number_format($record['price'],2),
'sale' => (float) number_format($record['price_sale'],2)
],