Try our conversational search powered by Generative AI!

On first add to basket validation returns PlacedPricedChanged (Commerce 11.2.6)


We have code for the basket which we have written that follows the quicksilver example in how line items are added to the basket.

_orderGroupRepository.CreateLineItem(code, cart);

It generally all works however when adding the item to the basket for the first time and calling the validate methods calling the workflow validation

                cart.ValidateOrRemoveLineItems((item, issue) => HandleError(issue, validationErrors), _lineItemValidator);
                cart.UpdatePlacedPriceOrRemoveLineItems(contact, (item, issue) => HandleError(issue, validationErrors), _placedPriceProcessor);
                cart.UpdateInventoryOrRemoveLineItems((item, issue) => HandleError(issue, validationErrors), _inventoryProcessor);

We are always getting PlacedPricedChanged returned back. It only happens on the first call however after that everything is fine? Can some advise why this is and how to resolve it?

Nov 17, 2017 17:11

On the phone right now, but IIRC  then when you create the line item there is no price. The processing code will then get the price and set it for you. So that is expected and nothing to worry about. You can of course set the price yourself but that means more work.

Nov 17, 2017 17:47

Thanks Quan you're always helpful, yeah I gather than because it's a fresh line item object it's got defaults but surely you don't want the validator to throw back a PlacedPricedChanged validation error when this happens on the first item.

I'm mapping these errors throw to validation messages show for when prices change and baskets are adusted. This means without some custom logic the end user will be shown validation messages, I was hoping the validator would be clever enough to know it's a new line item.

Nov 20, 2017 9:42

It might make senses to not add the warning if the price was null (i.e. this case). I'll file a bug and let my colleagues decide what to do with it. 

Nov 20, 2017 13:11

Thanks that's what I was thinking for now, just wanted to double check that it's designed to work like that. Thanks for the help

Nov 20, 2017 13:21
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.