Copied to clipboard

Flag this post as spam?

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


  • Denford 116 posts 257 karma points
    1 week ago
    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 116 posts 257 karma points
    1 week ago
    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 2758 posts 13973 karma points MVP 7x c-trib
    1 week ago
    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 116 posts 257 karma points
    1 week ago
    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 116 posts 257 karma points
    6 days ago
    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