How to construct the url link to be used to be able to create an add to cart button from an external page to add a product into nopcommerce. When the user click on add button from external page what url link can be used to do this? Thank you
Have a look at the following code from the add to cart button:
protectedvoid btnAddToCart_Click(object sender, CommandEventArgs e) { int productID = Convert.ToInt32(e.CommandArgument); int productVariantID = 0; if (ProductManager.DirectAddToCartAllowed(productID, out productVariantID)) { List<string> addToCartWarnings = ShoppingCartManager.AddToCart(ShoppingCartTypeEnum.ShoppingCart, productVariantID, new List<int>(), string.Empty, 1); if (addToCartWarnings.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } else { string productURL = SEOHelper.GetProductURL(productID); Response.Redirect(productURL); } } else { string productURL = SEOHelper.GetProductURL(productID); Response.Redirect(productURL); } }
Basically you can create a page or handler that accepts a product id in as a querystring an pass this ID to the ShoppingCartManager.AddToCart method.
Hope this helps, Ben
i want to do a product customizable in flash, so customer design the product (colors etc), then the customer press a button handler that pass through the cart process. can you explain me please, what are the steps you describe avobe , i have to create a page and paste that code?and then? how can i know the url to put the link in my product to "land" in the shopping cart with the product added? what about the price?
thank you !!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.