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
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.
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.
@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.
@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);
}
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
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.
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
@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.
@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.
is working on a reply...