Skip to content

Miva Multi-Add Documentation - ADPM#


Description#

9.0003 introduces a brand new action, ADPM which allows you to add multiple products to the cart (including their attributes) with a single form submit. It functions similarly to how the single product add to basket form submit works. Instead of accepting the usual g.Product_Code, g.Quantity, and g.Product_Attributes[] variables, ADPM expects a g.Products[] array. Within g.Products[] each index is expected to have a code and quantity member, and an optional attributes array.

If there are any errors, for example one of the products you added is out of stock, or is missing a required attribute, the action will add all other products and display all error messages on the screen. This makes it important that the page the user is taken to when they hit submit has the error messages array also on the page to be able to display the proper error messages.

Requirements#

Miva Version 9.3 and

CTGY Example#

<form method="post" action="&mvte:global:sessionurl;Screen=BASK">
    <input type="hidden" name="Action" value="ADPM">
    <input type="hidden" name="Attributes" value="Yes">
    <input type="hidden" name="Store_Code" value="&mvte:store:code;">

    <mvt:foreach iterator="product" array="category_listing:products">
        <input type="hidden" name="Products[ &mvt:product:id; ]:code" value="&mvte:product:code;">
        <input type="hidden" name="Products[ &mvt:product:id; ]:quantity" value="1">
        <mvt:item name="product_attributes" param="product:id" />
    </mvt:foreach>

    <input type="submit" value="Add to Basket">
</form>

In this example, the product attribute output would need to be modified as follows:

<mvt:foreach iterator="attribute" array="attributes">

<input type="hidden" name="Products[ &mvt:product:id; ]:attributes[ &mvt:attribute:index; ]:code" value="&mvte:attribute:code;">
<input type="text" name="Products[ &mvt:product:id; ]:attributes[ &mvt:attribute:index; ]:value" value="&mvte:attribute:value;" class="textfield">

</mvt:foreach>

Subscription Example#

The ADPM action also supports adding subscriptions.

<input type="hidden" name="Products[ 1 ]:subterm_id" value="xxx" />