Basket Empty

Vote:
 

Hi,

We have a 7.5 Episerver CMS and Commerce.

 The site has worked for over 8 years – and suddenly on the 16th Jan 2022 the commerce side of the website stopped working.

 When we add in an item to the Cart the cart is full – when it hits ListItemsSimpleView.ascx.cs in the BINDDATA method the Cart is still full but as soon as it hits this function

 CartHelper.RunWorkflow(Constants.CartValidateWorkflowName); - the workflow name is “CartValidate”.

 The Cart is empty 

 I have rolled back the code to a code sample of 2020 (2 years old) and it still throws the same error. Which is very odd.

 Can I ask – does CartHelper.RunWorkflow (which is part of Mediachase.Commerce.Orders.Managers) talk to any external APIs such as FIND or any EpiServer API that may have stopped working/de-commissioned OR changed?

SAMPLE OF CODE

private void BindData()

        {

            var isEmpty = CartHelper.IsEmpty;

           

            // Make sure to check that prices has not changed

            if (!isEmpty)

            {

                // restore coupon code to context

                string couponCode = Session[Constants.LastCouponCode] asstring;

                if (!String.IsNullOrEmpty(couponCode))

                {

                    MarketingContext.Current.AddCouponToMarketingContext(couponCode);

                }

 

                CartHelper.Cart.ProviderId = "FrontEnd";

 

                CartHelper.RunWorkflow(Constants.CartValidateWorkflowName);

 

                // If cart is empty, remove it from the database

                isEmpty = CartHelper.IsEmpty;

                if (isEmpty)

                    CartHelper.Delete();

 

                CartHelper.Cart.AcceptChanges();

            }

        

            if (!isEmpty)

            {

                string ProductName = "";

                try

                {

                    foreach (var v in CartHelper.LineItems)

                    {

                        var ce = CatalogContext.Current.GetCatalogEntry(v.ParentCatalogEntryId);

                        if (ce != null)

                        {

                            if (ce.Name != null && ce.Name != "")

                            {

                                ProductName = ce.Name;

                                break;

                            }

                        }

                    }

                    if (ProductName != "")

                    {

                        litEventName.Text = "<h2>" + ProductName + "</h2><hr/>";

                    }

                }

                catch (Exception ex)

                {

                    SendUserEmail(ex.Message, "ERROR BINDING");

                }

  

                lvCartItems.DataSource = CartHelper.LineItems;

                _promotionResult = CartHelper.GetPromotions();

            }

 

            lvCartItems.DataBind();

        }

#270522
Jan 25, 2022 15:47
Vote:
 

Check the state of the variant you are trying to add to the cart. If it's invalid in any way, it will get removed from the cart.

I.e. Inventory is zero, item availability has expired etc

#270609
Jan 26, 2022 18:55
Vote:
 

Hi Jonathan,

Check with the below code:

CartHelper.Cart.RunWorkflow(Constants.CartValidateWorkflowName);

#271045
Feb 02, 2022 14:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.