Umbraco.Commerce.Issues
Umbraco.Commerce.Issues copied to clipboard
Link the Store to the PricePropertyValue (in the PropertyValueConverter?)
To get a price from a PricePropertyValue
we need to supply a Currency ID that's configured in the store.
So to get a "default" price for a product we're using some extension methods that look something like this:
public static StoreReadOnly Store(this IProduct product) =>
product.AncestorOrSelf<StoreRoot>().Store;
public static Guid DefaultCurrencyId(this IProduct product) =>
product.Store().BaseCurrencyId.Value;
public static decimal GetDefaultPrice(this IProduct product) =>
product.Price.GetPriceFor(product.DefaultCurrencyId()).Value;
It strikes me though that at the point that the price was saved in the Backoffice, the property editor knew which Store the price was related to and the currency came from.
To cut down on boilerplate like this could the store itself be made available on the PricePropertyValue
?
i.e. PricePropertyValue.Store
It would then be trivial to add extension methods to do things like get a "default price" for the base currency etc.