We're officially retiring our Multi Add (opens new window) plugin, co-created by Jeremy Daalder (opens new window), but for all the right reasons. It's certainly proved useful for Commerce 1 and Craft 2, at the time, filling a gap in functionality for many.
With Commerce 2 (beta), all of Multi Add's functionality can be achieved natively - great news! Let's recap what Multi Add does, and how to transition.
​Adding Multiple Items To Your Cart#
Commerce 2 follows a similar pattern, but major changes are:
- Changing the "action" hidden input value.
- Changing the hidden input names from
items[]
topurchasables[]
And also some other minor Craft 3 changes as shown.
​Commerce 1 with Multi Add:#
<form method="POST">
<input type="hidden" name="action" value="multiAdd/multiAdd">
<input type="hidden" name="redirect" value="/cart">
{{ getCsrfInput() }}
{% for product in craft.commerce.products.find() %}
<input type="hidden" name="items[{{ loop.index }}][purchasableId]" value="{{ product.defaultVariant.id }}">
<input type="hidden" name="items[{{ loop.index }}][qty]" value="1">
<input type="text" name="items[{{ loop.index }}][note]">
<select name="items[{{ loop.index }}][options][color]">
<option value="blue">Blue</option>
<option value="white">White</option>
<option value="red">Red</option>
</select>
{% endfor %}
<input type="submit" value="Add to cart">
</form>
​Commerce 2:#
<form method="POST">
<input type="hidden" name="action" value="commerce/cart/update-cart">
{{ redirectInput('cart') }}
{{ csrfInput() }}
{% for product in craft.products.all() %}
<input type="hidden" name="purchasables[{{ loop.index }}][id]" value="{{ product.defaultVariant.id }}">
<input type="hidden" name="purchasables[{{ loop.index }}][qty]" value="1">
<input type="text" name="purchasables[{{ loop.index }}][note]">
<select name="purchasables[{{ loop.index }}][options][color]">
<option value="blue">Blue</option>
<option value="white">White</option>
<option value="red">Red</option>
</select>
{% endfor %}
<input type="submit" value="Add to cart">
</form>
Check the Commerce 2 docs (opens new window)
​Updating Multiple Items In Your Cart#
Often you'll need a button on your cart page to update multiple aspects of your customers cart at once. Commerce 2 follows a similar pattern, but major changes are:
- Changing the "action" hidden input value.
- Changing the hidden input names from "items[]" to "lineItems[]"
And also some other minor Craft 3 changes as shown.
​Commerce 1 with Multi Add:#
<form method="POST">
<input type="hidden" name="action" value="multiAdd/updateCart">
<input type="hidden" name="redirect" value="/cart">
{{ getCsrfInput() }}
{% for item in cart.lineItems %}
<input type="text" size="4" name="items[{{ item.id }}][qty]" value="{{ item.qty }}">
{% endfor %}
<button type="submit">Update Cart</button>
</form>
​Commerce 2:#
<form method="POST">
<input type="hidden" name="action" value="commerce/cart/update-cart">
{{ redirectInput('cart') }}
{{ csrfInput() }}
{% for item in cart.lineItems %}
<input type="text" size="4" name="lineItems[{{ item.id }}][qty]" value="{{ item.qty }}">
{% endfor %}
<button type="submit">Update Cart</button>
</form>
Check the Commerce 2 docs (opens new window)
​Thanks for the good times!#
We've officially stopped support for Multi Add for Craft 2, effective immediately. You'll always be able to have access to the plugin code on the Github (opens new window) repository, along with still being able to post issues. We'll do our best to help out any issues that creep up (along with the community being able to help), but we want to make it clear we're well and truly leaving Craft 2 behind, and looking forward to the future with Craft 3 + Commerce 2.
Thanks to everyone who has found Multi Add useful, and of course a shout out to Jeremy Daalder (opens new window) again!