Announcement

Collapse
No announcement yet.

Odd quirk getting price ranges on a page with multiple products

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Odd quirk getting price ranges on a page with multiple products

    Trying to track down an odd bug for a client. They had MIVA develop some collections pages, where there are multiple products listed on the page that can be added to a cart. Each product displays the price range for the variants if applicable. The price range is not consistently picking up the price range for a particular product if there are variants. I have combed through the code that I believe is driving those numbers, but cannot for the life of me figure out WHY it isn't only displaying the pricing for the particular product block.

    The magic variant number seems to be 4: once a product is listed that has more than 4 variants, the products after that display the first price of a previous product and fills in the correct prices after. Here are a couple of live examples:

    https://marigoldliving.com/sanya-riy...inkorange.html
    CHEVRON HAND STITCHED QUILT - PINK and products after are not picking up their price range, even though the attributes in the dropdown are listed correctly

    https://marigoldliving.com/aria-riya...ion-green.html
    same for the products at the bottom.

    I tried moving the order of the products around and got the same results. I am thinking that something is not resetting correctly at the beginning of the individual product block, but I am stumped. I backed down the code to the original from more than a few years ago, and the issue still persists. Unfortunately, they just noticed it, years after it was done.

    Code:
    readytheme => content => multi_prod_section - this drives the product grid from what I can tell

    <mvt:assign name="l.settings:multicodes" value="miva_array_deserialize(l.settings:codelist) " />
    <mvt:assign name="g.mvt_debug" value="miva_array_serialize( l.settings:codelist )" />
    <div id="prod-multiprod" class="column medium-np">
    <mvt:if expr="NOT ISNULL l.settings:codelist">
    <h3 class="palantino uppercase">Choose your items belows</h3>
    </mvt:if>
    <hr />
    <mvt:foreach iterator="code" array="multicodes">
    <mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Code_WithRuntimeInventory( l.settings:code, l.settings:multiprod )" />
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:multiprod:code, 'multi-descrip', g.multidescrip )" />
    <mvt:assign name="l.settings:index" value="POS1" />
    <form method="post" action="&mvte:urls:BASK:auto;" id="js-purchase-product_&mvt:multiprod:code;" name="add" class="multi-form form_&mvt:index;">
    <input type="hidden" name="Action" value="ADPR">
    <input type="hidden" name="Product_Code" value="&mvta:multiprod:code;">
    <input type="hidden" name="Old_Screen" value="&mvte:global:Screen;" />
    <mvt:if expr="l.settings:multiprod:customfield_values:cust omfields:product_flag NE 'none'">
    <mvt:assign name="l.settings:multiprod:flag" value="'flag--' $ tolower(l.settings:multiprod:customfield_values:cu stomfields:product_flag)" />
    </mvt:if>
    <div class="multi-product">
    <mvt:assign name="g.var" value="miva_array_serialize(l.settings:multiprod)" />
    <div class="column large-half whole medium-nlp">
    <div class="column small-one-third whole multiprod-image nlp">
    <span class="flag &mvt:multiprod:flag;">
    <mvt:do name="l.image_count" file="g.Module_Library_DB" value="ProductImageDataList_Load_Product(l.setting s:multiprod:id, l.settings:multiprod:images)" />
    <mvt:foreach iterator="image" array="multiprod:images">
    <mvt:assign name="l.settings:images" value="NULL" />
    <mvt:if expr="l.settings:image:imagetype:code EQ 'main'">
    <mvt:assign name="l.settings:images" value="l.settings:image" />
    <mvt:foreachstop/>
    </mvt:if>
    </mvt:foreach>
    <mvt:assign name="g.var" value="miva_array_serialize(l.settings:images)" />
    <mvt:if expr="NOT ISNULL l.settings:images">
    <img data-src="&mvte:images:image:image;" alt="&mvte:multiprod:name;" title="&mvte:multiprod:name;" />
    <mvt:else>
    <img data-src="../images/img_no_thumb.jpg" alt="&mvte:multiprod:name;" title="&mvte:multiprod:name;" />
    </mvt:if>
    <a class="uppercase quickview" data-product-link="&mvte:urls:PROD:auto_sep;product_code=&mvte: multiprod:code;&amp;show=quickview">Quick view</a>
    </span>
    </div>
    <div class="column small-two-thirds whole multiadd-text">
    <p class="multi-title">&mvt:multiprod:name;</p>
    <mvt:if expr="NOT ISNULL g.multidescrip">
    <p class="multi-descrip raleway">&mvt:global:multidescrip;</p>
    <mvt:else>
    <p class="multi-descrip raleway">&mvt:multiprod:descrip;</p>
    </mvt:if>
    </div>
    </div>
    <div class="column large-half whole">
    <div class="column large-three-fifths medium-half whole multiadd-attrib medium-nlp">
    <mvt:item name="product_attributes" param="multiprod:id" />
    <mvt:if expr="l.settings:product:inv_active OR l.settings:attributemachine:product:inv_active">
    <mvt:if expr="l.settings:product:inv_instock LE l.settings:prod:inv_low_level">
    <div id="js-inventory-message" class="raleway">
    <mvt:if expr="l.settings:product:inv_short OR l.settings:attributemachine:product:inv_short">
    <span class="teal-green">&mvt:product:inv_short;</span>
    <mvt:else>
    &mvt:product:inv_short;
    </mvt:if>
    <mvt:item name="customfields" param="Read_Product_Code( g.product_code, 'stock_date', g.stock )" />
    <mvt:if expr="l.settings:product:inv_short EQ 'Out of Stock!' OR l.settings:product:inv_low_level LE 2 AND NOT ISNULL g.stock">
    <span id="stock-date" class="raleway teal-green">Expected Date: &mvt:global:stock;</span>
    </mvt:if>
    </div>
    </mvt:if>
    </mvt:if>
    </div>
    <div class="column large-two-fifths medium-half whole multiadd-price medium-nrp">
    <div id="multi-instock-container_&mvt:multiprod:code">
    <mvt:item name="toolkit" param="attr|attr_count|l.all_settings:multiprod:id " />
    <mvt:if expr="g.attr_count GT 0">
    <mvt:item name="readytheme" param="contentsection( 'multi_variant_price' )" />
    <mvt:else>
    <!--flag-->

    <mvt:item name="customfields" param="Read_Product_Code( l.settings:code, 'product-flag', l.settings:customfields )" />
    <mvt:assign name="g.flag" value="tolower(l.settings:customfields )" />
    <mvt:if expr="l.settings:customfields NE 'none'">
    <div class="flag--&mvt:global:flag;">&mvt:customfields;</div>
    </mvt:if>

    <mvt:assign name=" l.settings:customfields" value=" " />
    <mvt:if expr="l.settings:multiprod:inv_available GT 0">
    <mvt:if expr="l.settings:multiprod:base_price GT l.settings:multiprod:price">
    <div>
    <strong class="strike">&mvt:multiprod:formatted_base_price ;</strong>
    <strong class="red">&mvt:multiprod:formatted_price;</strong>
    </div>
    <mvt:else>
    <mvt:do name="l.settings:result" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:multiprod:price )" />
    <div class="price-value"><strong>&mvt:result;</strong></div>
    </mvt:if>
    </mvt:if>
    </mvt:if>
    <mvt:if expr="g.attr_count EQ 0">
    <mvt:if expr="l.settings:multiprod:inv_available EQ 0">
    <mvt:assign name="hide" value="'hide'" />
    <mvt:else>
    <mvt:assign name="hide" value="''" />
    </mvt:if>
    <mvt:else>
    <mvt:assign name="hide" value="''" />
    </mvt:if>
    <div class="quantity-wrap &mvt:global:hide;">
    <div class="column two-thirds nlp">
    <span class="bg-gray decrease-quantity align-center" unselectable="on" data-rt-icon="&#x67;"></span>
    <input type="tel" name="Quantity" value="0" class="quantity-input">
    <span class="bg-gray increase-quantity align-center" unselectable="on" data-rt-icon="&#x69;"></span>
    </div>
    <mvt:if expr="l.settings:multiprod:inv_available LE l.settings:multiprod:inv_low_level">
    <div id="js-inventory-message_&mvt:multiprod:id;" class="column one-third nrp multi-inv hide js-inventory-message_&mvt:multiprod:code;">
    &mvt:product:inv_short;
    </div>
    </mvt:if>
    <div class="clear"></div>
    </div>
    </div>
    <mvt:if expr="g.attr_count EQ 0">
    <mvt:if expr="l.settings:multiprod:inv_available EQ 0">
    <div id="oos_&mvt:multiprod:code;" class="">
    <mvt:item name="customfields" param="Read_Product_Code(l.settings:multiprod:code , 'stock_date', l.settings:stockdate)" />
    <span class="multi-oos red uppercase align-left">Out of Stock</span>
    <mvt:if expr="NOT ISNULL l.settings:stockdate">
    <div class="multi-oos-date uppercase align-left">
    Expected Date <strong>&mvt:stockdate;</strong>
    </div>
    </mvt:if>
    <div class="multi-wait uppercase underline waitlist_new">
    <a href="Javascript:window.open('&mvt:global:sessionu rl;Store_Code=&mvta:global:store:code;&amp;Screen= WAITLIST&amp;Product_Code=&mvta:multiprod:code;&am p;show_wait=1','image','status=no,width=500,height =175').focus();">Email me When its back!</a>
    </div>
    </div>
    </mvt:if>
    <mvt:else>
    <div id="oos_&mvt:multiprod:code;" class="hide">
    <mvt:item name="customfields" param="Read_Product_Code(l.settings:multiprod:code , 'stock_date', l.settings:stockdate)" />
    <span class="multi-oos red uppercase align-left">Out of Stock</span>
    <mvt:if expr="NOT ISNULL l.settings:stockdate">
    <div class="raleway teal-green">Expected Date &mvt:stockdate;</div>
    </mvt:if>
    <div class="multi-wait uppercase underline waitlist_new">
    <a href="Javascript:window.open('&mvt:global:sessionu rl;Store_Code=&mvta:global:store:code;&amp;Screen= WAITLIST&amp;Product_Code=&mvta:multiprod:code;&am p;show_wait=1','image','status=no,width=500,height =175').focus();">Join the Waitlist </a>
    </div>
    </div>
    </mvt:if>
    <mvt:comment> <div class="multi-atw">
    <span data-mmnodisable="true">
    <span onClick="document.forms.add.action = '&mvtj:urls:WISH:secure;'; document.forms.add.elements.Action.value = 'ATWL';" class="small">
    <a class="atw raleway">Add to wishlist</a>
    </span>
    </span>
    </div></mvt:comment>
    </div>
    </div>
    </div>
    <hr class="breaker clear" />
    </form>
    <mvt:item name="attributemachine" param="body:multiprod:id" />
    </mvt:foreach>
    <div id="js-purchase-message-multi-add"></div>
    <div class="clear"></div>
    <mvt:if expr="l.settings:codelist">
    <button id="multi-submit" type="button" class="raleway multi-submit">Add to Cart</button>
    </mvt:if>
    </div>


    readytheme => content => multi_variant_price - this drives the price range snippet - I did verify that this is what is being used to display the price range. The pricehigh seems to be ok,,, but pricelow is wacky.

    <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: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:do file="g.Module_Library_DB" name="l.success" value="ProductVariantList_Load_Product_Option( l.settings:multiprod: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:multiprod:id, l.settings:part:variant_id, l.settings:variant )" />
    </mvt:foreach>

    <mvt:comment>
    ====Add Variant Prices to Array====
    </mvt:comment>
    <mvt:foreach iterator="var" array="variant">
    <mvt:if expr="l.settings:var:price NE 0">
    <mvt:assign name="l.addToArray" value="miva_array_insert( l.settings:option_prices, l.settings:var:price, -1 )" />
    <mvt:if expr="s.remote_addr EQ '100.3.92.237' "><mvt:eval expr="decodeattribute(glosub(miva_array_serialize( l.settings:var), ',', '<br>'))" /></mvt:if>
    </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:do file="g.Module_Library_Utilities" name="l.null" 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>

  • To reset the price range snippet, at the very bottom of the readytheme > content section > multi_variant_price add:

    Code:
    <mvt:assign name="l.settings:option_prices_length" value="miva_array_delete(l.settings:option_prices,1, miva_array_elements(l.settings:option_prices)) />
    http://www.alphabetsigns.com/

    Comment


    • Thanks for your response alphabet,,,, I gave that a try, but nothing changed. I thought it might be something like that so dug a bit deeper and somehow managed to get the right combination of clearing of values.

      Thanks for pointing me on the right track!

      Comment

      Working...
      X

      This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

      This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

      Accept