Announcement

Collapse
No announcement yet.

Quantity Limits Module Question

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

    #16
    This code requires the quanlimits item to be assigned to all pages. It checks for exception errors and updates messaging in the mini-basket or on the basket page to direct the shopper to modify their cart. It removes the option to proceed to checkout. If someone manages to get past these checks, the module will catch them on the OSEL page. The site I did this on is using the Levels theme, so the code will have to be modified accordingly.

    Code:
    Minibasket:
    
    <div id="js-mini-basket-container" class="column whole small-half large-one-third mini-basket-container">
    <div class="row mini-basket-content" data-itemcount="&mvt:global_minibasket:basket_count;" data-subtotal="&mvt:basket:formatted_total;">
    <span data-icon="&#xe051;" class="mini-basket-close" title="Close"></span>
    <h3 class="column whole np nm">Shopping Cart</h3>
    <div class="sky mini-basket-seperator">&bull;&bull;&bull;&bull;&bull;</div>
    <mvt:if expr="l.settings:global_minibasket:empty">
    <div class="breaker clear"></div>
    <p class="column whole align-center">Your cart is currently empty.</p>
    <mvt:else>
    <div class="column whole mini-basket-table-wrap custom-scrolling">
    
    <mvt:comment>Integrate Quantity Limits</mvt:comment>
    <mvt:foreach iterator="group" array="global_minibasket:groups">
    <mvt:item name="quanlimits" param="QuantityExceptionList_Load_Line( l.settings:group:group_id, l.settings:exceptions )" />
    </mvt:foreach>
    
    <mvt:assign name="g.total_count" value="miva_array_elements(l.settings:exceptions)" />
    <mvt:if expr="g.total_count GE 1">
    
    <mvt:comment>Create custom list of products in exception list to compare against. Don't display error if product already exists in list.</mvt:comment>
    <mvt:assign name="g.tqdbasket_exceptions" value="'|'" />
    
    <p class="message message-error">
    <mvt:assign name="g.counter" value="0" />
    <mvt:foreach iterator="exception" array="exceptions">
    <mvt:assign name="g.counter" value="g.counter + 1" />
    
    <mvt:comment>Exclude the exception if the product is already in the custom list of exception products</mvt:comment>
    <mvt:if expr="NOT(('|' $ l.settings:exception:product $ '|') IN g.tqdbasket_exceptions)">
    <span style="display: block;">Purchases of &mvte:exception:product; are limited to a total quantity of <b>&mvte:exception:max_quan;</b><mvt:if expr="g.counter LT g.total_count"><span></mvt:if>
    <mvt:assign name="g.purchase_exception" value="1" />
    </mvt:if>
    
    <mvt:comment>Add exception to custom list of exception products</mvt:comment>
    <mvt:assign name="g.tqdbasket_exceptions" value="g.tqdbasket_exceptions $ l.settings:exception:product $ '|'" />
    </mvt:foreach>
    <span style="display:block;">Please edit your cart.</span>
    </p>
    </mvt:if>
    
    <mvt:foreach iterator="item" array="global_minibasket:items">
    <div class="row mini-basket-row">
    <div class="column hide medium-show medium-one-fifth">
    <mvt:if expr="NOT ISNULL l.settings:item:imagetypes:main">
    <img src="&mvte:item:imagetypes:main;" alt="&mvt:item:name;" title="&mvt:item:name;" class="mini-basket-image">
    <mvt:else>
    &nbsp;
    </mvt:if>
    </div>
    <div class="column three-fourths medium-three-fifths">
    <a href="&mvte:urls:PROD:auto_sep;Product_Code=&mvta: item:code;">&mvt:item:name;</a>
    <mvt:if expr="l.settings:item:upsold">
    &nbsp;(Special Offer)
    </mvt:if>
    <br />
    <mvt:foreach iterator="option" array="item:options">
    <mvt:if expr="l.settings:option:option_id">
    &mvt:option:attr_prompt;: &mvt:option:opt_prompt;
    <mvt:elseif expr="NOT ISNULL l.settings:option:data">
    &mvt:option:attr_prompt;: &mvt:option:data;
    <mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
    &mvt:option:attr_prompt;: &mvt:option:data_long;
    <mvt:else>
    &mvt:option:attr_prompt;
    </mvt:if>
    <mvt:if expr="l.settings:option:price"> &mvt:option:formatted_price;</mvt:if>
    <br />
    </mvt:foreach>
    <mvt:if expr="l.settings:item:subterm_id">
    Subscription: &mvte:item:productsubscriptionterm:descrip;<br />
    </mvt:if>
    <!-- Qty: &mvte:item:quantity; -->
    </div>
    <div class="column one-fourth medium-one-fifth align-right np">
    <mvt:if expr="l.settings:item:subtotal_base_price OR l.settings:item:subtotal">
    <mvt:if expr="l.settings:item:subtotal_base_price NE l.settings:item:subtotal">
    <s>&mvt:item:formatted_subtotal_base_price;</s><br />
    </mvt:if>
    <strong>&mvt:item:formatted_subtotal;</strong>
    <mvt:else>
    <strong>&mvt:item:formatted_subtotal_comprehensive ;</strong>
    </mvt:if>
    </div>
    </div>
    </mvt:foreach>
    </div>
    <div class="breaker clear"></div>
    <h5 class="column whole align-right normal np">Subtotal: <strong>&mvt:global_minibasket:formatted_total;</strong></h5>
    </mvt:if>
    </div>
    <mvt:if expr="NOT l.settings:global_minibasket:empty">
    <div class="row">
    <mvt:if expr="g.purchase_exception EQ 1">
    <div class="column whole np"><a href="&mvte:urls:BASK:auto;" class="nb round-bottom-left button button-block button-medium button-square bg-gray white uppercase">Edit Cart</a></div>
    <mvt:else>
    <div class="column half np"><a href="&mvte:urls:BASK:auto;" class="nb round-bottom-left button button-block button-medium button-square bg-gray white uppercase">Edit Cart</a></div>
    <div class="column half np"><a href="&mvte:urls:OINF:secure;" class="nb round-bottom-right button button-block button-medium button-square bg-green white uppercase">Checkout</a></div>
    </mvt:if>
    <mvt:comment>Reset value of purchase_exception</mvt:comment>
    <mvt:assign name="g.purchase_exception" value="0" />
    </div>
    </mvt:if>
    </div>
    
    
    BASK - Main Template above Basket Contents:
    
    <mvt:foreach iterator="group" array="basket:groups">
    <mvt:item name="quanlimits" param="QuantityExceptionList_Load_Line( l.settings:group:group_id, l.settings:exceptions )" />
    </mvt:foreach>
    
    <mvt:assign name="g.total_count" value="miva_array_elements(l.settings:exceptions)" />
    <mvt:if expr="g.total_count GE 1">
    
    <mvt:comment>Create custom list of products in exception list to compare against. Don't display error if product already exists in list.</mvt:comment>
    <mvt:assign name="g.tqdbasket_exceptions" value="'|'" />
    
    <p class="message message-error">
    <mvt:assign name="g.counter" value="0" />
    <mvt:foreach iterator="exception" array="exceptions">
    <mvt:assign name="g.counter" value="g.counter + 1" />
    
    <mvt:comment>Exclude the exception if the product is already in the custom list of exception products</mvt:comment>
    <mvt:if expr="NOT(('|' $ l.settings:exception:product $ '|') IN g.tqdbasket_exceptions)">
    <span style="display: block;">Purchases of &mvte:exception:product; are limited to a total quantity of <b>&mvte:exception:max_quan;</b></span>
    </mvt:if>
    
    <mvt:comment>Add exception to custom list of exception products</mvt:comment>
    <mvt:assign name="g.tqdbasket_exceptions" value="g.tqdbasket_exceptions $ l.settings:exception:product $ '|'" />
    </mvt:foreach>
    <mvt:if expr="g.counter EQ 1">
    <span style="display: block;">Please adjust your purchase to the maximum allowed total quantity.</span>
    <mvt:else>
    <span style="display: block;">Please adjust your purchases to the maximum allowed total quantity of each product.</span>
    </mvt:if>
    </div>
    </mvt:if>
    
    
    BASK - Basket Contents:
    
    <mvt:comment>Disable checkout button if quantity limits exception list exists</mvt:comment>
    <mvt:if expr="NOT ISNULL g.tqdbasket_exceptions">
    <p class="align-center"><a title="Proceed to Secure Checkout" class="button button-block button-square button-medium bg-green white uppercase disabled">Checkout</a></p>
    <mvt:else>
    <p class="align-center"><a href="&mvt:global:secure_sessionurl;Screen=OINF&St ore_Code=&mvte:store:code;" title="Proceed to Secure Checkout" class="button button-block button-square button-medium bg-green white uppercase">Checkout</a></p>
    </mvt:if>
    
    PROD - Product Display Layout:
    
    Inside the add to cart form:
    <mvt:item name="quanlimits" param="QuantityLimit_Load_Product( l.settings:product:id, 0, l.settings:product:limits )" />

    Comment


      #17
      Thank you Leanne.!!! LOL the title of your post should have been Quantity Limits Module Answer
      Last edited by lesliekirk; 02-28-23, 04:51 AM.
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #18
        Originally posted by Ron Frigon View Post

        I don't believe this gets triggered until OCST is submitted. Not ideal...
        OMG - how did I forget about this??? I'm trying to get this module working in another store and I COMPLETELY forgot about this mess. Why can't this module just work like the store owner thought it would (like the EP module did).
        Leslie Kirk
        Miva Certified Developer
        Miva Merchant Specialist since 1997
        Previously of Webs Your Way
        (aka Leslie Nord leslienord)

        Email me: [email protected]
        www.lesliekirk.com

        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

        Comment


          #19
          Originally posted by Leanne View Post
          This code requires the quanlimits item to be assigned to all pages. It checks for exception errors and updates messaging in the mini-basket or on the basket page to direct the shopper to modify their cart. It removes the option to proceed to checkout. If someone manages to get past these checks, the module will catch them on the OSEL page. The site I did this on is using the Levels theme, so the code will have to be modified accordingly.
          Thanks once again for helping to make this module work better. The store I'm working on uses the Minimum Quantities. I may need a little help if I can't rework what you did for the maximums. I'll share what I do - if it works.

          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment

          Working...
          X