Adding multiple products to cart from URL

1 ay önce
Hi guys,
got stuck on this: like to add multiple products to cart via URL.

URL is:
https;//../AddToCart/itemid1=1&quantityitem1=1&itemid2=2&quantityitem2=5

Created Controller for View named "AddToCart".
In view "AddToCart":  reading what is written in the url.
Checking products + amount if they are valid and existing in table.
So far so good. But now:

How to add this to the cart properly?

Appreciate any help / hints on this.
1 ay önce
One way is to Customise the respective AddToCart routines
public override async Task<IActionResult> AddProductToCart_Details(int productId, int shoppingCartTypeId, IFormCollection form)
in src\Plugins\SSI\Nop.Plugin.Apollo.Appointments\Controllers\Public\CustomShoppingCartController.cs

Add a foreach loop and add each product individually in the list above
First loop through and check if there is any warnings / errors checking to add each item to the cart
if there are warnings / errors
       display errors and dont add any items to the cart
else
       loop through and add each item to the cart

You can also create you own custom route and routine and customise AddToCart.cshtml to call your routine for a particular product or scenario
onclick="AjaxCart.addproducttocart_details('@Url.RouteUrl("AddProductsToCart-YourProduct",
1 ay önce
Hi yida,

second solve is so smart and so shorthand!

Made my day, thanks a lot and have a good week.