Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Philip Hayton 98 posts 435 karma points
    Aug 29, 2021 @ 19:19
    Philip Hayton
    0

    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

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 30, 2021 @ 08:29
    Matt Brailsford
    100

    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 the ExtractProductName(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 the IUmbracoProductNameExtractor is the better option if you want to change how names are generated system wide.

  • Philip Hayton 98 posts 435 karma points
    Aug 30, 2021 @ 08:34
    Philip Hayton
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft