With this change you can select one of the variants that exist and with that you got information that can be passed on to the basket. Hope that will help.
I need to clarify: the change I suggested is just for you to see the "variantSku", at least it was so for me. I couldn´t see any variants so I suspected that you couldn´t either, but try out Sorens advice first.
Thanks for the replies, but I rewrote the store completely in c# (asp user controls instead of XSLTs). It seems uCommerce XSLT layer doesn' work well with my configuration (IIS 7.0, etc.). Now the store works fine, but I can't figure out how to add the product in basket from c# code.
The easiest way to add to basket from .NET is to use:
Library.AddToBasket(string catalogName, int quantity, string sku, string variantSku);
You need to make sure that the URL you're using is configured for a store, e.g. a hostname is configured in Umbraco and that same hostname is set for on the store level (the top level in uCommerce Admin in Product Catalog) in uCommerce.
Also you need to have the catalog name as part of the URL (myPage.aspx?catalog=MyCatalog) or you can override the current catalog to your current catalog name manually with the following code:
Just wanted to add a quick note about XSLT library and IIS7.
Our XSLT extensions work well with IIS7, in fact they are tested with both IIS6 and IIS7 and we haven't seen any issues particular to any of these IIS versions.
Problems with the XSLT extensions usually arise when the store isn't configured to work with a content node. The process of configuring a store with a URL is demonstrated in Installing and Configuring uCommerce Store.
But my basket is user independant. It is the same for all users and even when ClientContext.IsLoggedOn is false and ClientContext.CurrentMemberName is null. How can I get/create baskets for each user using your library?
uCommerce uses cookies to identify individual baskets so you need to make sure that cookies are enabled on your machine otherwise you'll get a new basket every time you add something to the basket. This will happen automatically inside the APIs so you shouldn't have to worry about it.
You can verify if this is the case by looking in the uCommerce_PurchaseOrder table. If you see new orders created in quick succession then you might have to look at whether a firewall or browser is blocking cookies on your site.
To retrieve the existing basket for a user you can use SiteContext.ClientContext.GetBasket(true) to get the current basket for a user. The true parameter tells uCommerce to create a new basket for that user if no basket exists in cookie or session to start from.
AddToBasket uses GetBasket internally and will create a new basket for you if you don't have one already.
I have tried everything to programmatically add a product to the basket, but cannot seem to get this to work with the latest UCommerce. I have tried both the XSLT.AddToBasket(), as well as the Basket() AddProduct methods. The error I am getting with the XSLT.AddToBasket() is 'The product with sku 'xxxxxxx' does not have a price in the price group "USD"'. I added the price group and can add the product to the cart from the front-end, but not via the API. I have set the context for the CatalogName and tried this in many different ways to no avail. Any assistance would be greatly appreciated!
Add to basket
Hello!
I can't figure out how to add products to basket via XSLT in the demo store.
What should be inserted into Product[XSLT].xslt to get this functionality?
There is AddToBasket[XSLT].xslt, but I don't understand what should be done with it.
Thank you.
Hi Garry,
Are products showing up in the store when you browse to its URL? You should be able to add products without changing any macros.
Hello Garry!
There are some minor errors with some of the alias and in the products.xslt file change following:
With this change you can select one of the variants that exist and with that you got information that can be passed on to the basket. Hope that will help.
--Björn Jönsson
Hello Garry!
I need to clarify: the change I suggested is just for you to see the "variantSku", at least it was so for me. I couldn´t see any variants so I suspected that you couldn´t either, but try out Sorens advice first.
Kind Regards
--Björn Jönsson
Hi Guys,
Thanks for the replies, but I rewrote the store completely in c# (asp user controls instead of XSLTs). It seems uCommerce XSLT layer doesn' work well with my configuration (IIS 7.0, etc.). Now the store works fine, but I can't figure out how to add the product in basket from c# code.
The easiest way to add to basket from .NET is to use:
You need to make sure that the URL you're using is configured for a store, e.g. a hostname is configured in Umbraco and that same hostname is set for on the store level (the top level in uCommerce Admin in Product Catalog) in uCommerce.
Also you need to have the catalog name as part of the URL (myPage.aspx?catalog=MyCatalog) or you can override the current catalog to your current catalog name manually with the following code:
Just wanted to add a quick note about XSLT library and IIS7.
Our XSLT extensions work well with IIS7, in fact they are tested with both IIS6 and IIS7 and we haven't seen any issues particular to any of these IIS versions.
Problems with the XSLT extensions usually arise when the store isn't configured to work with a content node. The process of configuring a store with a URL is demonstrated in Installing and Configuring uCommerce Store.
Thank you!
If one of the replies helped you solve the problem could you please mark it as the solution?
Thanks.
Just one more question regarding the baskets.
I'm using the recommended code to add products to basket.
But my basket is user independant. It is the same for all users and even when ClientContext.IsLoggedOn is false and ClientContext.CurrentMemberName is null.
How can I get/create baskets for each user using your library?
Thank you.
uCommerce uses cookies to identify individual baskets so you need to make sure that cookies are enabled on your machine otherwise you'll get a new basket every time you add something to the basket. This will happen automatically inside the APIs so you shouldn't have to worry about it.
You can verify if this is the case by looking in the uCommerce_PurchaseOrder table. If you see new orders created in quick succession then you might have to look at whether a firewall or browser is blocking cookies on your site.
To retrieve the existing basket for a user you can use SiteContext.ClientContext.GetBasket(true) to get the current basket for a user. The true parameter tells uCommerce to create a new basket for that user if no basket exists in cookie or session to start from.
AddToBasket uses GetBasket internally and will create a new basket for you if you don't have one already.
Hi,
I have tried everything to programmatically add a product to the basket, but cannot seem to get this to work with the latest UCommerce. I have tried both the XSLT.AddToBasket(), as well as the Basket() AddProduct methods. The error I am getting with the XSLT.AddToBasket() is 'The product with sku 'xxxxxxx' does not have a price in the price group "USD"'. I added the price group and can add the product to the cart from the front-end, but not via the API. I have set the context for the CatalogName and tried this in many different ways to no avail. Any assistance would be greatly appreciated!
Thanks!
Don
is working on a reply...