November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
I've mostly been using GetOrderByTrackingNumber in OrderRepository from the Commerce Starter Kit. I've also tried to use OrderContext directly, by calling the GetMostRecentPurchaseOrder method.
Hi,
I have to check for sure, but Cart/PurchaseOrder are "just another metaclasses". So if you want to load the metafields, you'll have to use MetaObject class - otherwise OrderContext will only returns the metaobject in master language.
Pseudo code:
var metaDataContext = OrderContext.MetaDataContext.Clone(); metaDataContext.UseCurrentThreadCulture = false; metaDataContext.Language = "no"; MetaObject.Load(metaDataContext, orderId, "PurchaseOrder");
Regards,
/Q
Awesome, that worked! :) Thanks a bunch, Quan.
I made a few extension methods to make it easier to use. Maybe they can be of use to someone else.
public static MetaDataContext GetClone(this MetaDataContext mdContext, string language) { var clonedMetaDataContext = mdContext.Clone(); clonedMetaDataContext.UseCurrentThreadCulture = false; clonedMetaDataContext.Language = language; return clonedMetaDataContext; }
public static MetaObject LoadMetaObject(this MetaStorageBase item, MetaDataContext context) { return MetaObject.Load(context, item.Id, item.MetaClass.Name); }
Hi,
I've created a few multi-language metafields for line item and managed to successfully set values for all enabled languages, verified by inspecting the purchase order's line items through the Commerce Manager UI. But, when retrieving the same purchase orders through any of the metods on OrderContext, all the multi-language fields are NULL. Is there some special way that the order needs to be retrieved for the multi-language fields to be populated, or is there some other trick to this? The custom fields that are not multi-language are populated as expected.
Edit: Commerce version is 9.22.0
Regards,
Per A