Adding Products Via QueryString

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hello everyone,
I have an microfiche for motorcycle parts located on another site that returns a querystring to my nopcommerce 1.9 site once the user is finished making their selections. I am currently trying to figure out how I can get these products added to my cart by using the information in the query string (SKU, make, description, price, qty).

I first tried using the ShoppingCartService.AddToCart() method to add the products but decided it would be better if I created a temporary Product object using the info from the querystring and then added that item to the cart with the AddToCart method. Am I on the right track using this method?

If so, then now the question remains, how do I create a product with only the given attributes (SKU, make, description, price, qty) which will be able to be passed to the (possibly overridden) AddToCart method?

Any help is greatly appreciated!
12 years ago
jimmyonthekeys wrote:
Hello everyone,
I have an microfiche for motorcycle parts located on another site that returns a querystring to my nopcommerce 1.9 site once the user is finished making their selections. I am currently trying to figure out how I can get these products added to my cart by using the information in the query string (SKU, make, description, price, qty).

I first tried using the ShoppingCartService.AddToCart() method to add the products but decided it would be better if I created a temporary Product object using the info from the querystring and then added that item to the cart with the AddToCart method. Am I on the right track using this method?

If so, then now the question remains, how do I create a product with only the given attributes (SKU, make, description, price, qty) which will be able to be passed to the (possibly overridden) AddToCart method?

Any help is greatly appreciated!


Would it be possible for you to use the product service and query for the product variant via SKU and pass the results on to the shopping cart service? Below is some pseudo code.


ProductVariant v = _productService.GetProductVariant(skuFromQueryString);

_shoppingCartService.AddToCart(customer, v, ... quantityFromQueryString, ...);

12 years ago
The problem is that none of the products actually exist in the database. I just need a 'dummy' product created to pass to the method to add it to the cart so that it will be treated as if it were a 'real' product.
12 years ago
jimmyonthekeys wrote:
The problem is that none of the products actually exist in the database. I just need a 'dummy' product created to pass to the method to add it to the cart so that it will be treated as if it were a 'real' product.


I'm not clear on if you actually want to create a part or not, but if you do, look at code in
...\src\Libraries\Nop.Services\ExportImport\ImportManager.cs
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.