Add multiple products to the basket at a time
Guide to implementing an 'add more to cart' feature, for example on landing pages or wholesale pages.
You can let customers add multiple products to the cart at once. This is done by using an array in the form instead of the normal 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 should contain product_id and amount.
You can also add attribute_value_id for variants and comment for comments per product.
Do you need help? Contact us at support@shoporama.dk.
Related articles
Sort products on a landing page
Guide to sorting products on Shoporama landing pages by different parameters.
Add a comment to a product in your cart
Learn how to add a comment field to products in the basket - for engraving, gift wrapping or other customer requests.
Alternate products in multi-language shops
Guide to creating hreflang alternate tags for products in Shoporama stores running in multiple languages.