Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have implemented the simple Child Variants.
But when I add the Variant to the cart, in my cart > orderlines I only get the name of my variant for example: "red" when really I should show the Product Name + Variant name like: "Baseball red"
Do I have to collect the parent name manually like so?
var productName = product.Name;
productName = product.Parent.Name + " " + productName;
Am I doing something wrong? What is the best way to go with this?
If using child node variants, you need to do 1 of 3 things.
1) Pass both the parent product node key + the child variant product node key in a AddProduct method with a signature that accepts a productNodeReference and a productVariantReference
2) Implement a custom IUmbracoProductNameExtractor to extract a products name based on any rules you define.
3) Pass a productName property to the added order line to explicitly set the name when adding your product.
Ultimately, given just the child variant node on it's own, Vendr has no idea whether it is a variant or product node, so you need to tell in some way "this is actually a variant of this product" via one of the mechanisms above.
thanks for your reply.
Which option have you used in the demo store?
If I should decide to pass a productName property to the added order line to explicitly set the name when adding the product. Would I pass the value like so:
using (var uow = _unitOfWorkProvider.Create())
var store = CurrentPage.GetStore();
var order = _sessionManager.GetOrCreateCurrentOrder(store.Id)
.AddProduct(postModel.ProductReference, postModel.ProductVariantReference, postModel.Quantity);
order.SetProperty("productName", postModel.ProductName );
Is there allready a property on the order with has the alias "productName"?
In the demo store we go the route of the IUmbracoProductNameExtractor which you can see here https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore/Web/Extractors/CompositeProductNameExtractor.cs and registered here https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore/Composing/DemoStoreComposer.cs#L18
If you want to pass the product name to the orderline, you'll want to pass it as part of the AddProduct call which can accept a dictionary of properties. You need it to be an Order Line property, but the example you have you are setting an Order level property.
And no, there isn't already a productName property that is captured, this is just used as a mechanism to bypass the normal name generation should you wish to.
Hope this helps
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted