Announcement

Collapse
No announcement yet.

Multi-Product Add To Cart on the View Order Page

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

    Multi-Product Add To Cart on the View Order Page

    I had searched on the forum and had looked at miva documents (and http://docs.miva.com/how-to-guides/s...ti-product-add) and was not able to see how to add a "Reorder All" button so that a customer can just reorder a complete previous order with one click (same order) - including the quantities that were ordered. I do have the "Reorder" button for each individual product and can add each item one at a time, but I am looking to place a button "Reorder All" where the customer can duplicate an old order and re-order all items at once - including quantity. Can this be done? Thanks.


    #2
    I've implemented this on one of our sites. Add all to cart with previous quantities, with item attributes, displays an out of stock message for out of stock items with purchased quantity. You'll need to edit this to fit your store. We don't use the actual order status... so those fields are commented out. Basic cssui.

    Code:
    <script>
        function ReloadForm(form_field){
            document.location.reload();
            document.getElementsByName("OrderDetails_Format").value=form_field;
        };
    </script>
    <div class="info-message align-center">
                To Re-Order &quot;All Items&quot; click the &quot;Add All to Cart&quot; button below. Quantities to re-order can be edited, or changed to &quot;0&quot;, in the Quantity column.
    </div>
    <form method="post" action="&mvte:global:secure_sessionurl;Screen=BASK">
    <input type="hidden" name="Action" value="ADPM">
    <table class="basket">
        <thead>
            <tr id="basket-header-row">
                <td class="align-left" colspan="2"><input type="submit" value="Add All to Cart" class="cta-button"></td>
                <td class="align-left"><strong>Product</strong></td>
                <!-- <td class="align-left"><strong>Status</strong></td> //-->
                <td><strong>Quantity</strong></td>
                <td class="align-right"><strong>Price</strong></td>
                <td class="align-right"><strong>Subtotal</strong></td>
            </tr>
        </thead>
        <tbody>
            <mvt:foreach iterator="item" array="order:items">
                <tr class="basket-prod-row">
                    <td class="order-reorder">
                        <mvt:if expr="((l.settings:item:reorder EQ 1) AND (l.settings:item:product:inv_level NE 'out'))">
                                      <a href="&mvt:global:sessionurl;&Screen=PROD&Product_Code=&mvta:item:code;" class="button" title="View &mvt:item:name;">View</a>
                        </mvt:if>
                    </td>
                    <td class="align-center">
                <mvt:if expr="ISNULL l.settings:item:imagetypes:main_image">
                    &nbsp;
                <mvt:else>
                    <img src="&mvte:item:imagetypes:main_image;" alt="&mvte:item:name;" />
                </mvt:if>
                    </td>
                    <td class="prod">
                        <p>
                            <strong>&mvt:item:name;</strong>
                            <mvt:if expr="l.settings:item:upsold">
                                &nbsp;(Special Offer)
                            </mvt:if>
                        </p>
                        <mvt:foreach iterator="option" array="item:options">
                            <mvt:if expr="l.settings:option:option_id">
                                <p>&mvt:option:attr_prompt;: <strong>&mvt:option:opt_prompt;</strong></p>
                            <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                                <p>&mvt:option:attr_prompt;: <strong>&mvt:option:data;</strong></p>
                            <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn">
                                <p>&mvt:option:attr_prompt;: <strong>&mvt:option:data_logn;</strong></p>
                            <mvt:else>
                                <p>&mvt:option:attr_prompt;</p>
                            </mvt:if>
                        </mvt:foreach>
                    </td>
                    <!-- <td>&mvt:item:order_status;</td> //-->
                    <mvt:if expr="((l.settings:item:reorder EQ 1) AND (l.settings:item:product:inv_level NE 'out'))">
                                <mvt:assign name="l.settings:order:item_counter" value="l.settings:order:item_counter + 1"/>
                                <td><input type="hidden" name="Products[ &mvte:order:item_counter; ]:code" value="&mvt:item:code;">
                                <input type="text" name="Products[ &mvte:order:item_counter; ]:quantity" value="&mvt:item:quantity;" class="textfield align-center bold">
    
                    <mvt:foreach iterator="option" array="item:options">
                      <mvt:assign name="l.settings:item:option_counter" value="l.settings:item:option_counter + 1"/>
    
                      <!--begin item option-->
                      <input type="hidden" name="Products[ &mvte:order:item_counter; ]:attributes[ &mvte:item:option_counter; ]:code" value="&mvte:option:attr_code;" />
    
                      <mvt:if expr="l.settings:option:opt_code"> 
                      <!--opt_code--><input type="hidden" name="Products[ &mvte:order:item_counter; ]:attributes[ &mvte:item:option_counter; ]:value" value="&mvte:option:opt_code;" />
    
                      <mvt:elseif expr="l.settings:option:data">
                        <mvt:comment>Strip out new lines and carriage returns</mvt:comment>
                        <mvt:assign name="l.settings:option:data" value="glosub(l.settings:option:data, asciichar( 10 ), '')" />
                        <mvt:assign name="l.settings:option:data" value="glosub(l.settings:option:data, asciichar( 13 ), '')" />
                      <!--data--><input type="hidden" name="Products[ &mvte:order:item_counter; ]:attributes[ &mvte:item:option_counter; ]:value" value="&mvte:option:data;" />
    
                      <mvt:elseif expr="l.settings:option:opt_data_long">
                      <!--opt_data_long--><input type="hidden" name="Products[ &mvte:order:item_counter; ]:attributes[ &mvte:item:option_counter; ]:value" value="&mvte:option:opt_data_long;" />
    
                      <mvt:else>   
    
                        <input type="hidden" name="Products[ &mvte:order:item_counter; ]:attributes[ &mvte:item:option_counter; ]:value" value="1" />
    
                      </mvt:if>
                     <!--end item option-->
                    </mvt:foreach>
                    </td>
                    <mvt:else>
                    <td><div class="error-message">(&mvt:item:quantity;) &mvt:item:product:inv_short;</div></td>
                    </mvt:if>
                    <td class="align-right">
                        <p>
                            <mvt:if expr="l.settings:item:price EQ '0' OR l.settings:item:price EQ '0.00' OR l.settings:item:price EQ 0.00 OR l.settings:item:price EQ 0">
                                &nbsp;
                            <mvt:else>
                                &mvt:item:formatted_price;
                            </mvt:if>
                        </p>
                        <mvt:foreach iterator="option" array="item:options">
                            <mvt:if expr="l.settings:option:price">
                                <p>&mvt:option:formatted_price;</p>
                            </mvt:if>
                        </mvt:foreach>
                    </td>
                    <td class="align-right">
                        <p>
                            <mvt:if expr="l.settings:item:price EQ '0' OR l.settings:item:price EQ '0.00' OR l.settings:item:price EQ 0.00 OR l.settings:item:price EQ 0">
                                &nbsp;
                            <mvt:else>
                                &mvt:item:formatted_subtotal;
                            </mvt:if>
                        </p>
                        <mvt:foreach iterator="option" array="item:options">
                            <mvt:if expr="l.settings:option:price">
                                <p>&mvt:option:formatted_subtotal;</p>
                            </mvt:if>
                        </mvt:foreach>
                    </td>
                </tr>
            </mvt:foreach>
            <tr>
            <td colspan="2"><input type="submit" value="Add All to Cart" class="cta-button"></td>
            <td colspan="4">&nbsp;</td>
            </tr>
        </tbody>
    </table>
    </form>
    <div id="totals" class="clearfix">
        <div>
            <mvt:foreach iterator="charge" array="order:charges">
                <p class="charges"><em>&mvt:charge:descrip;:</em> &mvt:charge:formatted_disp_amt;</p>
            </mvt:foreach>
            <p class="total"><strong>Total:</strong> &mvt:order:formatted_total;</p>
        </div>
    </div>
    Ron Frigon
    Jedi Webmaster Obi-Ron Kenobi

    Comment


      #3
      Thank you so much Ron!!! Exactly what I needed and am working on layout.

      Comment


        #4
        You're welcome Mish! This is one of the best uses of the Multi-Add function I think. Don't think there's any documentation for this, but with some pro tips here in the forums I was able to figure it out.

        Cheers!
        Ron Frigon
        Jedi Webmaster Obi-Ron Kenobi

        Comment

        Working...
        X