If you want to follow the standard convention I'd suggest downloading and looking at Quicksilver from GitHub. This is the reference project for using commerce, some examples of how they are using this for the RunWorkflow can be found here https://github.com/OXXAS/CommerceStarterKit/blob/master/src/common/Core/Services/CartService.cs
Sorry wrong link, that's a commerce starter kit Quicksilver is here https://github.com/episerver/Quicksilver
Not sure what you linked Scott, but I suppose you meant this? :P https://github.com/episerver/Quicksilver. The other one looks to be an old clone of Quicksilver, so it might work still :)
<insert slowpoke meme here>
In later version (11+) you no longer have to use workflow to validate your cart. However for consistency between frontend and Commerce Manager you should use at least Commerce 12 (which you do).
Your code only works if the implementation of ICart is the "old" Cart. If you switch to SerializableCart mode then it will not be working.
This is a fairly standard snippet of code to validate a cart, it should work with all implementation
var validationIssues = new Dictionary<ILineItem, List<ValidationIssue>>(); cart.ValidateOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _lineItemValidator); cart.UpdatePlacedPriceOrRemoveLineItems(_customerContext.GetContactById(cart.CustomerId), (item, issue) => validationIssues.AddValidationIssues(item, issue), _placedPriceProcessor); cart.UpdateInventoryOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _inventoryProcessor); ApplyDiscounts(cart); // Try to validate gift items inventory and don't catch validation issues. cart.UpdateInventoryOrRemoveLineItems((item, issue) => { validationIssues.AddValidationIssues(item, item.IsGift ? ValidationIssue.RemovedGiftDueToInsufficientQuantityInInventory : issue); }, _inventoryProcessor);
Thank you team.
Quan,
by default( commerce 12.4) SerializableCart will works or we need change any config. Cart operation and checkout api are same for SerializableCart or else SerializableCart have different process for cart and checkout
commerce ver:12.4
Hi Team,
We switching the carthelper to Iorderrepository.In the validate cart code used in carthelper is below one
we changed the above code for suitable to Icart like below,
Note: we are not using default epi inventory.
suggest me the above code is correct or it needs to change?
Please help me out.
Advance Thanks,
Regards,
karthik