Add multiple products to the cart at once
A guide to building an add-multiple-to-cart feature, for example on landing pages or wholesale pages.
You can let customers add multiple products to the cart at once. You do this by using an array in the form instead of the usual single-product format.

Code example from a landing page
<form action="" method="post">
<{section name="i" loop=$products}>
<h3><{$products[i]->getName()|escape}></h3>
<input type="hidden"
name="add_to_basket[<{$smarty.section.i.index}>][product_id]"
value="<{$products[i]->getProductId()}>"/>
<input type="number"
name="add_to_basket[<{$smarty.section.i.index}>][amount]"
value="0" min="0"/>
<{/section}>
<input type="submit" value="Add to cart"/>
</form>
The key is to use add_to_basket as an array with an index for each product. Each element must contain product_id and amount.
You can also add attributes for variants and comment for a comment on each product.
Need help? Contact us at support@shoporama.dk.
Related articles
Sort products on a landing page
How to sort the products on a landing page in Shoporama, automatically or in your own order with drag and drop, and how to choose a default sorting...
Add a comment field to products in the cart
Learn how to add a comment field to products in the cart, for example for engraving, name printing, or a gift greeting.
Hreflang and multilingual stores in Shoporama
How Shoporama sets hreflang, x-default, and html lang for your countries, what happens to untranslated pages, and how to handle your own hreflang...