Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Did you save your cart after running validation? Because
ValidateOrRemoveLineItems
should remove line items with variant deleted, however it does not save the cart
Ok, that might be it! And you only have to save it if there are any validation issues I guess?
That was it! In one place I did a validation without saving the cart, thanks Quan!
Hi!
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?
/Kristoffer