Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Feb 06, 2019 @ 14:50
    MB
    0

    Adding product name to orderline along with variant name

    I'm using Umbraco 7.11.1 with Tea Commerce 3.2.4

    Hi guys,

    I'm working on implementing variants on a shop but another little challenge has arise.

    When adding a product with a variant to the basket, it cannot find the product name, only the variant name.

    This is likely because I don't use the property productName but rather the page title. Is it possible to implement a fallback so the page title of the product is used, rather than a property entitled productName?

    // Mike

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Feb 06, 2019 @ 15:02
    Matt Brailsford
    1

    Hi Mike,

    Hmm, this should actually be how this works. It's the product information extractor that is in control of pulling out the product information and it does already have this fallback:

    https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/770705bdea8f20fd9e146c27724c9a830454c8e0/Source/TeaCommerce.Umbraco.Configuration/InformationExtractors/PublishedContentProductInformationExtractor.cs#L123

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Feb 06, 2019 @ 15:07
    Matt Brailsford
    100

    Ahh, are you saying it's showing the variant name and not the master product name?

    If so, you might want to add the master product name as an OrderLineProperty (see docs here on how to do it: https://docs.teacommerce.net/3.3.0/api/order-line/#addorupdateorderline the second example is passing some properties to the orderline) then update your cart to display the orderlines master product name, rather than the variant name.

    Hope this helps

    Matt

  • MB 273 posts 936 karma points
    Feb 06, 2019 @ 15:54
    MB
    2

    Matt.. It's getting increasingly embarrassing seeing your name with a solution in every post I make....

    It works as a CHARM! For those in my shoes, here's the solution:

    First: Add the correct input fields on your product page, here's an example of my code:

        <form method="post" action="/base/TC/FormPost.aspx" class="ajaxForm" data-product-id="@productPage.Id">
                        <input name="AddOrUpdateOrderLine" value="productIdentifier, quantity, properties" type="hidden" />
                        <input name="storeId" value="@storeId" type="hidden" />
                        <input name="productIdentifier" value="@productPage.Id" type="hidden" />
                        <input name="quantity" value="1" type="hidden" />
                        @* Below are my two custom fields *@
                        <input name="productNameInput" value="@CurrentPage.Name" type="hidden" />
                        <input name="properties" value="productNameInput" type="hidden" />
    

    Second: Go to your shopping cart and add the following line to display the custom property:

    @orderLine.Properties["productNameInput"]
    

    REMEMBER: You'd probably like to add the Master Product Name to these places as well:

    • Edit-order.cshtml
    • email-template-confirmation.cshtml
    • Cartstep1.cshtml
    • Cartstep4.cshtml
    • Cartstep5

    Voila, works like a charm!

    Thank you Matt for the solution

    // Mike

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Feb 06, 2019 @ 16:04
    Matt Brailsford
    0

    Hehe, it's my job 😁

    Glad you got it working. And thanks again for sharing the full solution 👍

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft