Hi David, I believe I finally could solve the issue.
I just built an empty Web project, then I added Umbraco package and then Ucommerce package. Because I'm learning the API and I want to build from the scratch.
To avoid the aforementioned error I set my current catalog in the context:
// Setting Catalog
var catalogId = new Guid("704F3A60-0C46-4071-BC73-7A6D4943A895");
var catalog = CatalogLibrary.GetCatalog(catalogId);
CatalogContext.CurrentCatalog = catalog;
By setting up the current catalog then I can create the basket, add products and get the total with not problems.
So in my future implementation the first thing I have to do is to set the current catalog in the contetxt.
No basket exists for the current user
I just created an MVC Empty site, then installed Umbraco package , then configured Umbraco and then installed Ucommerce package.
In my controller method I want to run this:
transactionLibrary.AddToBasket(quantity: 2, sku: "100-000-001", variantSku: "001");
var amount = transactionLibrary.GetBasket().OrderTotal;
But in the last line I'm getting the error: No basket exists for the current user
System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. Parameter name: No basket exists for the current user.
Thanks in advance
Hi Junanga,
Did you follow the documentation here? https://docs.ucommerce.net/ucommerce/v9.2/getting-started/transaction-foundation/basket.html
If you are still having the problem do you think you could upload a little more of your code so we can help debug it.
Regards
David
Also does that Sku and the variant exist?
Hi David, I believe I finally could solve the issue. I just built an empty Web project, then I added Umbraco package and then Ucommerce package. Because I'm learning the API and I want to build from the scratch.
To avoid the aforementioned error I set my current catalog in the context:
// Setting Catalog
var catalogId = new Guid("704F3A60-0C46-4071-BC73-7A6D4943A895");
var catalog = CatalogLibrary.GetCatalog(catalogId);
CatalogContext.CurrentCatalog = catalog;
By setting up the current catalog then I can create the basket, add products and get the total with not problems.
So in my future implementation the first thing I have to do is to set the current catalog in the contetxt.
Thanks and regards
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.