Is there a quick way to find the Shipping address using the order ID?
I am getting the order ID from the OrderFinalizedNotification.
I could not find anything in the Vendr Documentation about obtaining the address
The address is held in an orders properties collection using whatever property aliases you used to set them. With an order I’d you can fetch the order from the order service and get the address from it’s properties collection.
You can then access the value by reading the properties back
var shippingAddressLine1 = order.Properties["shippingAddressLine1"]?.Value;
var shippingAddressLine2 = order.Properties["shippingAddressLine2"]?.Value;
var shippingCity = order.Properties["shippingCity"]?.Value;
...
Maybe also try looking in the confirmation email template for another example of reading the values back.
Getting Address from Order ID
Hi Matt,
Is there a quick way to find the Shipping address using the order ID? I am getting the order ID from the OrderFinalizedNotification. I could not find anything in the Vendr Documentation about obtaining the address
/Victor
Hi Victor,
The address is held in an orders properties collection using whatever property aliases you used to set them. With an order I’d you can fetch the order from the order service and get the address from it’s properties collection.
Matt
Hi Matt, Sorry to ask but do you have a link for some documentation or an example? When looking at the order service at https://vendr.net/docs/core/1-2-0/reference/vendr-core-services/iorderservice/, I can not find any reference to a country property?
Hi Victor,
We don't have any concept of an address because it's completely up to you what you name them. What code are you using to set the address on the order?
If you take a look at the demo store implementation you'll see the address is stored in the order properties https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore/Web/Controllers/CheckoutSurfaceController.cs#L86
You can then access the value by reading the properties back
Maybe also try looking in the confirmation email template for another example of reading the values back.
/Matt
Hi Matt, Thanks a lot! It is all working now!
Fantastic. Glad we were able to get you there 👍
/Matt
is working on a reply...