Originally posted by kitdang
View Post
Announcement
Collapse
No announcement yet.
The MM 10.01.01 update broke the Multi Products Price Range snippet
Collapse
X
-
-
-
One approach that seems to work well in circumventing this Miva bug since 10.01.01 is to override the default AttributeMachine.prototype.Pricing_Update function. For example, if the product has attributes defined but no current variant has been selected, then display the formatted_price as the existing contents of price_div instead of $0.00.
Here's the code we used on our Product Display template under Attribute Machine > Head Template:
Code:AttributeMachine.prototype.Pricing_Update = function( data ) { var i, i_len, price, formatted_price, formatted_additional_price; if ( this.settings.price === 'retail' ) { price = data.retail; formatted_price = data.formatted_retail; } else if ( this.settings.price === 'base' ) { price = data.base_price; formatted_price = data.formatted_base_price; } else { price = data.price; formatted_price = data.formatted_price; } // If the item has attributes defined but a variant has not currently been selected, set the formatted_price display to the current contents of price_div // This allows for a variant price range to be displayed instead of $0.00 (e.g. https://docs.miva.com/code-samples/variant-price-range) if ( typeof data.attributes !== 'undefined' && typeof data.variant == 'undefined' ) formatted_price = this.price_div.innerHTML; if ( ( this.settings.additionalprice === 'retail' ) && ( price < data.retail ) ) { formatted_additional_price = data.formatted_retail; } else if ( ( this.settings.additionalprice === 'base' ) && ( price < data.base_price ) ) { formatted_additional_price = data.formatted_base_price; } else { formatted_additional_price = ''; } if ( this.price_div ) this.price_div.innerHTML = formatted_price; if ( this.additional_price_div ) this.additional_price_div.innerHTML = formatted_additional_price; if ( this.discount_div && this.settings.displaydiscounts ) { this.discount_div.innerHTML = ''; for ( i = 0, i_len = data.discounts.length; i < i_len; i++ ) { this.discount_div.appendChild( this.Generate_Discount( data.discounts[ i ] ) ); } } }
Leave a comment:
-
We are encountering this exact issue as well after upgrading to 10.01. The price range is being replaced with the parent products price of $0. You can see an example on https://store.iblp.org/the-pineapple...ple-story.html
As some have suggested, I can set a default variant, and the product page displays the price of that variant, but it doesn't highlight which variant is selected. Either way gives a confusing message to the customer.
It seems like displaying a price range for variant products is a pretty standard Miva template customization, with numerous examples available online. I am just not sure how we can achieve this in version 10.01. As others have pointed out, the price range is correctly displayed on the initial load, but reset by the attribute engine.
The product does have attributes that are mapped to inventory variants, so the attribute engine needs to be on for the user to select the desired attribute. But the price range also needs to be displayed on the initial page load so the customer can see the range of prices available before they select a specific variant. It seems rather misleading to show $0 since this is not a free product.
I am not finding a good way to work around this... Is there a recommended solution, or are we waiting for a bug fix on this issue?
Leave a comment:
-
Originally posted by Brennan View PostThis appears be related to the changes we made to support dynamic price changes without using inventory variants. Now regardless if you have inventory variants, attribute machine is initialized on the page. Attribute machine takes over the element with the id you have defined:
id="js-price-value-&mvt:multiprod:id;"
So what appears to be happening is your code is output, then Attribute Machine initializes and overwrites the price to the default price which appears to be 0.00 in this case.
A couple solutions: If attribute machine is not needed on this page, you can simply remove the ids from the page or from attributes machines settings in the admin for this screen.
If you do need attribute machine on some products but not others you can create copies of the page template without attribute machine or remove the ids conditionally via template code. Here is a simple example of checking to see if a product has variants and then modifying the output of the ids on the page:
Code:<mvt:foreach iterator="attribute" array="attributes"> <mvt:if expr="l.settings:attribute:inventory EQ 1"> <mvt:assign name="g.product_has_variants" value="1" /> </mvt:if> </mvt:foreach> <mvt:if expr="g.product_has_variants EQ 1"> <span id="price-value" itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> <mvt:else> <span itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> </mvt:if>
Leave a comment:
-
Originally posted by Brennan View PostThis appears be related to the changes we made to support dynamic price changes without using inventory variants. Now regardless if you have inventory variants, attribute machine is initialized on the page. Attribute machine takes over the element with the id you have defined:
id="js-price-value-&mvt:multiprod:id;"
So what appears to be happening is your code is output, then Attribute Machine initializes and overwrites the price to the default price which appears to be 0.00 in this case.
A couple solutions: If attribute machine is not needed on this page, you can simply remove the ids from the page or from attributes machines settings in the admin for this screen.
If you do need attribute machine on some products but not others you can create copies of the page template without attribute machine or remove the ids conditionally via template code. Here is a simple example of checking to see if a product has variants and then modifying the output of the ids on the page:
Code:<mvt:foreach iterator="attribute" array="attributes"> <mvt:if expr="l.settings:attribute:inventory EQ 1"> <mvt:assign name="g.product_has_variants" value="1" /> </mvt:if> </mvt:foreach> <mvt:if expr="g.product_has_variants EQ 1"> <span id="price-value" itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> <mvt:else> <span itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> </mvt:if>
It looks like the template was created to check to see if there are variants, then load them (keep in mind I am not the author of this code). Reviewing the products themselves, the ones with attributes are using Inventory Variants. Not sure if you saw the code I was referring to
Code:<mvt:comment> ====Load Product Attributes==== </mvt:comment> <mvt:do file="g.Module_Library_DB" name="l.success" value="AttributeList_Load_Product(l.settings:multi prod:id, l.settings:loaded_attributes)" /> <mvt:if expr="l.settings:loaded_attributes[1]:attemp_id GT 0"> <mvt:do file="g.Module_Feature_ATT_DB" name="l.success" value="AttributeTemplateAttrList_Load_Template(l.s ettings:loaded_attributes[1]:attemp_id, l.settings:loaded_attributes)" /> </mvt:if> <mvt:comment> ====Load Product Attribute Options + Add Option Prices to Array==== </mvt:comment> <mvt:assign name="l.settings:option_prices" value="''" /> <mvt:foreach iterator="attribute" array="loaded_attributes"> <mvt:assign name="l.settings:loaded_options" value="NULL" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="OptionList_Load_Attribute(l.settings:attrib ute:id, l.settings:loaded_options)" /> <mvt:foreach iterator="option" array="loaded_options"> <mvt:if expr="l.settings:option:price NE 0"> <mvt:assign name="l.addToArray" value="miva_array_insert( l.settings:option_prices, l.settings:option:price, -1 )" /> </mvt:if> <mvt:comment> ====Check if Product has Variants + Load the Variant Part==== </mvt:comment> <mvt:assign name="l.settings:variantPart" value="NULL" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantList_Load_Product_Option( l.settings:product:id, l.settings:attribute:id, l.settings:option:id, l.settings:variantPart )" /> <mvt:if expr="l.settings:variantPart[1]"> <mvt:comment> ====Load the Variant Information==== </mvt:comment> <mvt:foreach iterator="part" array="variantPart"> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Variant( l.settings:product:id, l.settings:part:variant_id, l.settings:variant )" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantPricing_Load_Variant(l.settin gs:product:id, l.settings:part:variant_id, l.settings:juan)" /> </mvt:foreach> <mvt:comment> ====Add Variant Prices to Array==== </mvt:comment> <mvt:foreach iterator="var" array="variant"> <mvt:if expr="l.settings:var:price GT 0"> <mvt:assign name="l.addToArray" value="miva_array_insert( l.settings:option_prices, l.settings:var:price, -1 )" /> </mvt:if> </mvt:foreach> </mvt:if> </mvt:foreach> </mvt:foreach> <mvt:comment> ====Sort Prices Array + Push First and Last Numbers into Variables==== </mvt:comment> <mvt:assign name="l.settings:priceLow" value="NULL" /> <mvt:assign name="l.settings:priceHigh" value="NULL" /> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="QuickSortArray( l.settings:option_prices, NULL, 1 )" /> <mvt:do name="l.settings:priceLow" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:option_prices[1] )" /> <mvt:do name="l.settings:priceHigh" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:option_prices[miva_array_elements(l.settings:option_prices)] )" /> <div id="js-price-value-&mvt:multiprod:id;" data-base-price="&mvt:multiprod:price;" class="price-value nm bold inline-block">&mvt:priceLow; - &mvt:priceHigh;</div> <div id="js-inventory-message-&mvt:multiprod:id;" class="raleway"> </div> <mvt:assign name="l.settings:option_prices" value="miva_array_delete(l.settings:option_prices, 1, miva_array_elements(l.settings:option_prices))" />
How would I go about tweaking for this?
Leave a comment:
-
This appears be related to the changes we made to support dynamic price changes without using inventory variants. Now regardless if you have inventory variants, attribute machine is initialized on the page. Attribute machine takes over the element with the id you have defined:
id="js-price-value-&mvt:multiprod:id;"
So what appears to be happening is your code is output, then Attribute Machine initializes and overwrites the price to the default price which appears to be 0.00 in this case.
A couple solutions: If attribute machine is not needed on this page, you can simply remove the ids from the page or from attributes machines settings in the admin for this screen.
If you do need attribute machine on some products but not others you can create copies of the page template without attribute machine or remove the ids conditionally via template code. Here is a simple example of checking to see if a product has variants and then modifying the output of the ids on the page:
Code:<mvt:foreach iterator="attribute" array="attributes"> <mvt:if expr="l.settings:attribute:inventory EQ 1"> <mvt:assign name="g.product_has_variants" value="1" /> </mvt:if> </mvt:foreach> <mvt:if expr="g.product_has_variants EQ 1"> <span id="price-value" itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> <mvt:else> <span itemprop="price" content="&mvt:product:price;">&mvt:product:formatt ed_price;</span> </mvt:if>
Leave a comment:
-
lesliekirk I noticed the same exact issue after the update and for a while thought I was crazy and haven't had the time to try to track down the issue. But my coding is different than yours.
Code:<mvt:if expr="g.low_price EQ '0.00' AND g.high_price EQ '0.00' AND l.settings:product:price EQ '0.00'"> <span class="x-product-layout-purchase__pricing-current u-color-olive"> <span id="price-value" itemprop="price" content="&mvt:attributemachine:product:price;"> &mvt:product:customfield_values:customfields:price _range;</span></span> <mvt:elseif expr="l.settings:product:price EQ '0.00'"> <span class="x-product-layout-purchase__pricing-current u-color-olive"> <span id="price-value" itemprop="price" content="&mvt:product:price;">&mvt:global:low_price_formatted; - &mvt:global:high_price_formatted;</span> </span> <mvt:else> <span class="x-product-layout-purchase__pricing-current u-color-olive"> <span id="price-value" itemprop="price" content="&mvt:product:price;">$&mvt:product:price; </span> </span> </mvt:if>
Leave a comment:
-
You can verify that this content div is being written into and then overwritten by opening your browser's inspector and throttling down the connection.
If this is the case, you can look at the ID (or class, but its usually ID) of the price container and then search for JS or jQuery for the function that does this. (This could very well be the js that is auto generated by miva, so you'll want to open those files from within inspector to search for the js or jquery function.
Or you could wait for Matt to chime in with the real answer :)
Leave a comment:
-
The MM 10.01.01 update broke the Multi Products Price Range snippet
Would anyone happen to know why this snippet would stop working after the latest update 10.01.01? I have confirmed it still works perfectly in the site before the update. It no longer shows the attribute price range after the update. Another oddity, if you refresh the page https://marigoldliving.com/sanya-riy...inkorange.html (at least in Firefox) you can catch a glimpse of the price range before it goes to $0.00.
This &mvt:priceLow; - &mvt:priceHigh; no longer displays - why?
Code:<mvt:comment> ====Load Product Attributes==== </mvt:comment> <mvt:do file="g.Module_Library_DB" name="l.success" value="AttributeList_Load_Product(l.settings:multi prod:id, l.settings:loaded_attributes)" /> <mvt:if expr="l.settings:loaded_attributes[1]:attemp_id GT 0"> <mvt:do file="g.Module_Feature_ATT_DB" name="l.success" value="AttributeTemplateAttrList_Load_Template(l.s ettings:loaded_attributes[1]:attemp_id, l.settings:loaded_attributes)" /> </mvt:if> <mvt:comment> ====Load Product Attribute Options + Add Option Prices to Array==== </mvt:comment> <mvt:assign name="l.settings:option_prices" value="''" /> <mvt:foreach iterator="attribute" array="loaded_attributes"> <mvt:assign name="l.settings:loaded_options" value="NULL" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="OptionList_Load_Attribute(l.settings:attrib ute:id, l.settings:loaded_options)" /> <mvt:foreach iterator="option" array="loaded_options"> <mvt:if expr="l.settings:option:price NE 0"> <mvt:assign name="l.addToArray" value="miva_array_insert( l.settings:option_prices, l.settings:option:price, -1 )" /> </mvt:if> <mvt:comment> ====Check if Product has Variants + Load the Variant Part==== </mvt:comment> <mvt:assign name="l.settings:variantPart" value="NULL" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantList_Load_Product_Option( l.settings:product:id, l.settings:attribute:id, l.settings:option:id, l.settings:variantPart )" /> <mvt:if expr="l.settings:variantPart[1]"> <mvt:comment> ====Load the Variant Information==== </mvt:comment> <mvt:foreach iterator="part" array="variantPart"> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Variant( l.settings:product:id, l.settings:part:variant_id, l.settings:variant )" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantPricing_Load_Variant(l.settin gs:product:id, l.settings:part:variant_id, l.settings:juan)" /> </mvt:foreach> <mvt:comment> ====Add Variant Prices to Array==== </mvt:comment> <mvt:foreach iterator="var" array="variant"> <mvt:if expr="l.settings:var:price GT 0"> <mvt:assign name="l.addToArray" value="miva_array_insert( l.settings:option_prices, l.settings:var:price, -1 )" /> </mvt:if> </mvt:foreach> </mvt:if> </mvt:foreach> </mvt:foreach> <mvt:comment> ====Sort Prices Array + Push First and Last Numbers into Variables==== </mvt:comment> <mvt:assign name="l.settings:priceLow" value="NULL" /> <mvt:assign name="l.settings:priceHigh" value="NULL" /> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="QuickSortArray( l.settings:option_prices, NULL, 1 )" /> <mvt:do name="l.settings:priceLow" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:option_prices[1] )" /> <mvt:do name="l.settings:priceHigh" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:option_prices[miva_array_elements(l.settings:option_prices)] )" /> <div id="js-price-value-&mvt:multiprod:id;" data-base-price="&mvt:multiprod:price;" class="price-value nm bold inline-block">&mvt:priceLow; - &mvt:priceHigh;</div> <div id="js-inventory-message-&mvt:multiprod:id;" class="raleway"> </div> <mvt:assign name="l.settings:option_prices" value="miva_array_delete(l.settings:option_prices, 1, miva_array_elements(l.settings:option_prices))" />
Tags: None
Leave a comment: