November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
It is still working the same. If you are using ICart, you can access the metafields via Properties property
Thank you Quan,
We already using some common extension method like below.How could replace this with cart.properties[name]=value;
using System; using Mediachase.Commerce.Orders; namespace xxxx.Common.Infrastructure.Extensions { public static class OrderStorageBaseExtention { public static void SetCustomField<T>(this OrderStorageBase obj, string fieldName, T value) { try { obj.SetMetaField(fieldName, value); } catch (Exception e) { throw e; } } public static T GetCustomField<T>(this OrderStorageBase obj, string fieldName) { try { var value = obj[fieldName]; return (value is T) ? (T)value : default(T); } catch (Exception e) { throw e; } } } }
Regards,
Karthik
public static class IExtendedPropertiesExtensions { public static string GetString(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], string.Empty); } public static bool GetBool(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], false); } public static Guid GetGuid(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], Guid.Empty); } public static int GetInt32(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], default(int)); } public static DateTime GetDateTime(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], DateTime.MaxValue); } public static decimal GetDecimal(this IExtendedProperties extendedProperties, string fieldName) { return DefaultIfNull(extendedProperties.Properties[fieldName], default(decimal)); } private static T DefaultIfNull<T>(object val, T defaultValue) { return val == null || val == DBNull.Value ? defaultValue : (T)val; } }
For set I would just use
cart.Properties["Name"] = value;
Hi Team,
Currently, we are using commerce 10.2.1.To set cart meta fields like below
For set custom field function
But commerce 12.4 how can I achieve this.
Advance thanks,
Regards,
Karthik