Hi Sapna,
I don't think all properties need to be loop for setting an OrderAddress to Shipping Address, you're doing correctly. I just don't know your whole code.
Could you try this:
var orderRepository = ServiceLocator.Current.GetInstance(); var cart = orderRepository.LoadOrCreateCart(customerId, _defaultName); var address = cart.CreateOrderAddress(); address.Id = "FakeOrderAddressID"; // This is required. address.FirstName = "Son"; address.LastName= "Do"; address.Line1 = "2134 Aurelle Rd, Strong, AR, 71765"; // ... address.Properties["YourMetaFieldName"] = "sample property value"; cart.GetFirstShipment().ShippingAddress = address; var _cartLink = orderRepository.Save(cart);
And this is the result:
For working with Cart, we could refer to this document https://world.episerver.com/documentation/developer-guides/commerce/orders/order-manipulation/.
Hope this helps,
/Son Do
I think address might be root cause this issue. It need to be created this way:
var address = cart.CreateOrderAddress();
Could you show us the code how to create address? And you're using SerializableCart mode or Legacy?
I don't find any special thing with those codes. It should work as expected :-?
Yes, we have done all that. And addr is not null.
Please try below link for screen shot
https://www.screencast.com/t/ysO0gS43y3A
Ah, I remember we have a bug for this issue before https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2017/3/order-address-metafields-saving-issue/
and it was fixed. Could you upgrade to latest Commerce version and try again.
When doing _orderGroup.GetFirstShipment().ShippingAddress = address; metafields are not getting carried over. Do we need to do this manually with a foreach loop on address.Properties?