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.
Du kan lade kunder lægge flere produkter i kurven på én gang. Det gøres ved at bruge et array i formularen i stedet for det normale enkelt-produkt-format.

Kodeeksempel fra en landingsside
<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="Læg i kurv"/>
</form>
Nøglen er at bruge add_to_basket som et array med et indeks for hvert produkt. Hvert element skal indeholde product_id og amount.
Du kan også tilføje attributes for varianter og comment for kommentarer pr. produkt.
Har du brug for hjælp? Kontakt os på 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.
Hreflang and alternate tags for multilingual webshops
Guide to creating hreflang alternate tags for products in Shoporama stores running in multiple languages.