Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Aichinger 3 posts 73 karma points
    Feb 03, 2021 @ 11:15
    David Aichinger
    0

    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.

    @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.

    enter image description here

    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)

    enter image description here

    enter image description here

    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/)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Feb 05, 2021 @ 20:45
    Alex Skrypnyk
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft