We recently updated our solution to version Episerver Commerce 9.24.0. We make use of a number of meta fields that we have created on OrderForm object.
We have been using SetMetaField to set such values:
cartHelper.Cart.OrderForms.SetMetaField("METAFIELD_NAME", metafieldValue, false);
The issue we're having is that when we then run cartHelper.Cart.AcceptChanges() the metafield value is lost.
The affected properties are of boolean type, but this issue may not be limited to boolean types.
One workaround we have found is to use cartHelper.Cart.OrderForms["METAFIELD_NAME"] = metafieldValue; The subsequent call to save the changes then saves the values as expected.
Any ideas on whether this is known version issue or what causes it?
You are calling that method with validate = false (the last parameter). validate = false means the the value type is not checked and the state of the object (OrderForm) is not changed. When you try to save, as the state of the object is not changed, it'll skip saving.
You should use the default value of validate (true) instead.
Thanks for your reply Quan.
I've tested with the default for "validate" and can confirm it also saves.