If you want to replace how Vendr extracts the product name you can replace the IUmbracoProductNameExtractor with your own implementation. You'll need to override the ExtractProductName(IPublishedContent content, IPublishedElement variantContent, string languageIsoCode) and have it retrieve / return the name you require.
An alternative approach can also be adding a productName property to the order line as this will override any generated name, however this will require you to provide the product name for every order line, so this is generally the better option when you only need to override the odd name here and there, where as replacing the IUmbracoProductNameExtractor is the better option if you want to change how names are generated system wide.
Variant Names
Hi guys,
How do you override the default naming convention for Variants when they are added to an order?
At the moment they include the Parent Product's name, but for our use case it we'd prefer it to just be the variants name.
Cheers
Phil
Hi Phil,
If you want to replace how Vendr extracts the product name you can replace the
IUmbracoProductNameExtractor
with your own implementation. You'll need to override theExtractProductName(IPublishedContent content, IPublishedElement variantContent, string languageIsoCode)
and have it retrieve / return the name you require.You can review the docs here for details on how you replace a Vendr implementation https://vendr.net/docs/core/1.8.0/key-concepts/dependency-injection/#replacing-dependencies
An alternative approach can also be adding a
productName
property to the order line as this will override any generated name, however this will require you to provide the product name for every order line, so this is generally the better option when you only need to override the odd name here and there, where as replacing theIUmbracoProductNameExtractor
is the better option if you want to change how names are generated system wide.Excellent thank you, I'll have a play with both approaches to see which one fits best.
Thanks again for the super swift response.
Cheers
is working on a reply...