Copied to clipboard

Flag this post as spam?

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


  • Denford 132 posts 323 karma points
    Sep 15, 2020 @ 11:05
    Denford
    0

    Cart Variant names not including main product name

    Trying to work out the logic behind how the cart names are generated as my variants names dont seem to be picking up the main product name e.g. if my product is called : Jeffries Forest Mulch Bags and the variant is : 50 Litres would like my cart displayed name to be : Jeffries Forest Mulch Bags - 50 Litres but currently its only : - 50 Litres, see images below

    enter image description here

    enter image description here

  • Denford 132 posts 323 karma points
    Sep 15, 2020 @ 11:08
    Denford
    0

    Also is there any logic out of the box that i can use to update the displayed price on a product page when a variant is changed from the dropdown, if not can look to implement something.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 15, 2020 @ 12:20
    Matt Brailsford
    100

    Hi Denford,

    Looking in the code for how this is worked out, it looks like when using variants, it does try to pull the name of the parent product, but it's looking explicitly for a property on the parent product with the alias productName, so looks like you will need to define that property and populate it with the name of the product (maybe setup an Umbraco event handler to auto populate it based on the name).

    I'm guessing this doesn't use the node name in case you want to name the page something different.

    RE your second question, the best I can suggest is to take a look at the code in the demo store. Here is the JS for it https://github.com/TeaCommerce/Tea-Commerce-Starter-Kit-for-Umbraco/blob/master/Source/TeaCommerce.StarterKit.Website/Scripts/product.js and here is the product page view https://github.com/TeaCommerce/Tea-Commerce-Starter-Kit-for-Umbraco/blob/master/Source/TeaCommerce.StarterKit.Website/Views/Product.cshtml

    Hope this helps

    Matt

  • Denford 132 posts 323 karma points
    Sep 15, 2020 @ 23:07
    Denford
    0

    @matt thanks have added a new property on the variant doc type called "productName" and that is pulling through in the cart, will leave it manual for now so they can set it to what ever name they want.

    As for updating the displayed price on variant change will have a look at that and let you know how i get on.

  • Denford 132 posts 323 karma points
    Sep 20, 2020 @ 12:37
    Denford
    0

    @matt ended up adding my extra logic in the product.js, so in the filteredVariants logic where it finds the single filtered variant, added an id to my price display field and then updates its html like below.

     //INSERT CODE HERE
     var priceDisplay = form.find('[id="productPrice"]');
     var price = TC.getPrice({ storeId: 1, productIdentifier: productIdentifier });
     if (price) {
                     priceDisplay.html(price.withVatFormatted);
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft