Deleted variant still in cart? [12.8]



If I place a variant in my shopping cart and the delete the variant from the catalog the variant is still loaded into the cart.  Even if I restart everything the variant is still loaded.

This code gives me the deleted variant:

var lineItems = cart.GetAllLineItems();
var variantReferences = _referenceConverter.GetContentLinks(lineItems.Select(l => l.Code))
                .Select(c => c.Value).Where(c => !ContentReference.IsNullOrEmpty(c));
var variants = _contentLoader.GetItems(variantReferences,_preferredCulture).OfType().ToList();

These validations are run:

cart.ValidateOrRemoveLineItems((item, issue) => issues.AddValidationIssues(item, issue), _lineItemValidator);
cart.UpdateInventoryOrRemoveLineItems((item, issue) => issues.AddValidationIssues(item, issue), _inventoryProcessor);
cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings());
cart.UpdateInventoryOrRemoveLineItems((item, issue) => { }, _inventoryProcessor);       

I get all information about the variant even though it is deleted, but I can't get an url to the item which I guess is how it is supposed to be.

Is this Episerver standard or maybe I'm missing something here?


Nov 22, 2018 15:17

Did you save your cart after running validation? Because 


should remove line items with variant deleted, however it does not save the cart 

Nov 22, 2018 15:57

Ok, that might be it! And you only have to save it if there are any validation issues I guess?

Nov 22, 2018 17:47

That was it! In one place I did a validation without saving the cart, thanks Quan!

Nov 22, 2018 19:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.