Ucommerce basket orderlines get deleted when switching context
Hello everyone!
I started a demo project to get familiar with Ucommerce for Umbraco. Within the catalog library (category navigation, product detail pages etc.) everything works fine, but when it comes to transaction library (putting stuff into my basket) i have some great troubles.
@inherits Umbraco.Web.Mvc.UmbracoViewPage<UComBP.Models.ProductModel>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<h2>This is the product detail page of "@Model.Name"</h2>
<h3>Price: @Model.Price</h3>
<button>Add to basket</button>
<script type="text/javascript">
$("button").click(function () {
$.ajax({
type: "POST",
url: '/Umbraco/Surface/ToCart/[email protected]',
contentType: "application/json; charset=utf-8",
});
});
public class ToCartController : SurfaceController
{
[HttpPost]
public ActionResult AddProduct(string sku)
{
ITransactionLibrary transactionLibrary = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<ITransactionLibrary>();
transactionLibrary.AddToBasket(1, sku);
return null;
}
}
This works as expected. I can also put the same product into the basket a second time. Quantity in the orderline counts up, as expected.
But when i switch to the details page of any other product (for example: https://localhost:44395/services/p/apps/ios-app) , all orderlines inside my basket get deleted, while the basketId stays the same. (basketId cookie is still there, and doesn't change it's value)
When i add a product (on the details page) and switch directly to my basket page (https://localhost:44395/cart), there is only the last kind of product, i added inside my basket.
Anybody knows what to do here to get this working?
Ucommerce basket orderlines get deleted when switching context
Hello everyone!
I started a demo project to get familiar with Ucommerce for Umbraco. Within the catalog library (category navigation, product detail pages etc.) everything works fine, but when it comes to transaction library (putting stuff into my basket) i have some great troubles.
On my product details page (for example: https://localhost:44395/services/p/apps/android-app), i have a button, which triggers an ajax request, to put the product into the basket.
This works as expected. I can also put the same product into the basket a second time. Quantity in the orderline counts up, as expected.
But when i switch to the details page of any other product (for example: https://localhost:44395/services/p/apps/ios-app) , all orderlines inside my basket get deleted, while the basketId stays the same. (basketId cookie is still there, and doesn't change it's value)
When i add a product (on the details page) and switch directly to my basket page (https://localhost:44395/cart), there is only the last kind of product, i added inside my basket.
Anybody knows what to do here to get this working?
Setup details:
Visual Studio Version: v16.8.3
Umbraco Installation: v8.10.2
Ucommerce: v9.3.1.20275 (I'm using the free version => https://ucommerce.net/pricing/free/)
Hi David,
I believe that uCommerce devs are helping on a separate forum - https://eureka.ucommerce.net/#!/
try to ask there as well
Thanks, Alex
is working on a reply...