For a site I developed the catalog name was paased on the querystring so when the user posted back the product they wanted to add to their basket I used the following code. Taking the fields form the request:
var addToBasketResult = UCommerce.Xslt.Library.AddToBasket(catalogName, int.Parse(postedQuantity), postedSku, postedVariant);
var pipelineResult = UCommerce.Xslt.Library.ExecuteBasketPipeline();
@Ole: If you're working with a single catalog you could override the default catalog context implementation in /umbraco/ucommerce/components.config and hardcode the catalog.
Alternatively you can bake the catalog name into the rewrite rules, against assuming you just have the one catalog.
Or you can just maintain the catalog querystring parameter in the URL - uCommerce will handle this for you if you generate catalog URL using the default UrlService.
SiteContext.Current.CatalogContext.CurrentCatalogName is null
Having trouble adding products to my basket.
I need to provide product catalog when calling AddProduct on the PurchaseOrder
Should this SiteContext.Current.CatalogContext.CurrentCatalogName set itself or is it up to me as dev to maintain this on each server roundtrip?
If yes i would appriciate some c# inspiration on how you maintain this var.
If no what am i missing?
Thanks in advance
Ole
Hello,
For a site I developed the catalog name was paased on the querystring so when the user posted back the product they wanted to add to their basket I used the following code. Taking the fields form the request:
@Ole: If you're working with a single catalog you could override the default catalog context implementation in /umbraco/ucommerce/components.config and hardcode the catalog.
Alternatively you can bake the catalog name into the rewrite rules, against assuming you just have the one catalog.
Or you can just maintain the catalog querystring parameter in the URL - uCommerce will handle this for you if you generate catalog URL using the default UrlService.
Hello John and Søren
Thanks for the feedback!
I will take a look at the UrlService
is working on a reply...