Can multiple items be added to the cart using 'nsc.fn.addToBasket()'?

So the below link will add an item to the cart… Can this same function ( nsc.fn.addToBasket() ) be used to add multiple items to the Basket?

The following link will only add one item to the cart, even though the function is called two times onClick:

<a href="javascript:void(0)" onclick="nsc.fn.addToBasket(1234, 1); nsc.fn.addToBasket(2345, 1);" id="add-to-basket-button">Add to Basket</a>

So, how can we add multiple items to the cart onClick? the jQuery.fn.addToBasket() function does not appear to accept arrays…

Any assistance would be appreciated. I am more than happy to implement the code myself, I just need the knowledge to do so. Thanks

Hi Derek,

The AJAX function currently only supports adding one at a time. I guess you could loop through the selected items and add them individually in sequence.

Regards,
Donogh

For sure. We are adding a “Frequently Bought Together” section on the Product Page. I was hoping there was an alternate AJAX “Add to Cart” function that accepted an array. All good though. Thanks for the response! I will post my final product.

1 Like