Precision prices are creating quite the problem for discount price display after Miva Merchant 10.11.01 update for a lot of store owners.
Discounts are showing prices like $12.330123 instead of $12.33 on the CTGY
, PROD
, SRCH
and possibly INVC
and some email templates, among others.
So how do we fix this? One way is to create a readytheme content section that will adjust the formatted price which is used to display the price.
Step 1. Make a New Readytheme Content Section
Go to:
USER INTERFACE > THEME COMPONENTS > CONTENT SECTIONS
Click the blue button, Add Content Section
Name: Function: Price Format for 2 Decimal Places
Code: function_price_format
Content:
<mvt:if expr="l.settings:product:price">
<mvt:do file="g.Module_Store_Module_Currency" name="l.settings:product:formatted_price" value="CurrencyModule_AddFormatting(l.settings:module, (l.settings:product:price ROUND 2))" />
</mvt:if>
Wrap In a DIV Tag: OFF
Step 2: Using this in a Page
The code below refers to the Shadows framework but will work in any Miva Merchant framework.
Usually the product price variable is l.settings:product:price
however there may be cases when it's in some other variable. If this happens the condition above can easily be updated to include other price variables. If you need help with this let us know.
The code below works on the PROD
, CTGY
, and SRCH
templates. The precision bug appears to affect discounted prices so find the <s>
tag and use this function there.
.....
<mvt:if expr="l.settings:product:base_price GT l.settings:product:price">
<span class="x-product-list__price u-color-gray-30"><s>&mvt:product:formatted_base_price;</s></span>
<mvt:comment>
#
# fixes decimal problem
#
</mvt:comment>
<mvt:item name="readytheme" param="contentsection( 'function_price_format' )" />
<span class="x-product-list__price u-color-red">&mvt:product:formatted_price;</span>
<mvt:else>
<span class="x-product-list__price">&mvt:product:formatted_price;</span>
</mvt:if>
.....