Miva Merchant Modules and Development
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.

PRECISION PRICES: Fix Precision Price Bug

Scot Ranney • December 05, 2024


Precision prices are popping up all over the place after Miva Merchant 10.11.01 update, especially in discounts/price group stuff.

The errors of $12.330123 instead of $12.33 are showing up on the CTGY, PROD, SRCH templates and possibly others.

A quick fix is to create a readytheme pseudo-function content section.

Readytheme 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

Usage in a Page

The content section assumes that the price is found in l.settings:product:price however this could easily be updated to include more conditionals for the price variable.

The code below shows it being called in the proper place, code is basically the same for PROD, CTGY, and SRCH. The precision bug appears to affect discounted prices only 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>


https://www.scotsscripts.com/mvblog/precision-prices-fix-precision-price-bug.html

mvkb_precision mvkb_price