Commerce adds parentnode to productname in cart

Hi there,

If I add a product to my cart, the productname changes to “Parentnode-name product-name”.
I’ve searched around and asked an AI, and it seems to be “by design” for variants if you don’t have a field productName.

However, I have a product that doesn’t have any variants. And still, the parent node gets added to the name when added to a cart.

I’m testing with the following site-structure:

When I add the “Ram Standaard” product to my cart, it ends up as “Producten - Ram Standaard”.

When I add a productName property, it’s still the same. Only instead of the nodeName it uses the productName value. But still adds the name of the parent node.

Is this a bug or do I need to add a custom product adapter to alter this naming?

Hi @cryothic

I don’t think it’s a bug. The parent name only gets prepended when Umbraco Commerce is looking at a variant product. So a standalone product getting the prefix suggests the node is being treated as a variant product even with no variants defined.

From your doctype icon it looks like you’re using a variant product type, that would explain why adding productName only changed the name source but kept the prefix.

Try setting it up as a plain non-variant product and the parent name should disappear. I checked it on a v17 UC project I have with a non-variant product and the parent name does not get prefixed.

Justin

Hi @justin-nevitech
First of all, congrats on winning the AI Package Award last wednesday. I didn’t get to congratulate you in person, as I didn’t run in to you and I’m not the person to stalk someone around :smiley:

We have used the Doctypes from the Commerce Demo Shop. Do you happen to know what defines a ‘non-variant product’? Is that simply a product that doesn’t allow children? I can’t find any switch or setting that would make the distingtion.

Hi @cryothic

Thanks! It’s so busy at Codegarden with lots of people, I would have happily stopped and chatted but I’m also not the most outgoing of people! I hope you had a great time though?

A non-variant product is a product that does not have any child or complex variants, as described in the following doc:

https://docs.umbraco.com/umbraco-commerce/key-concepts/product-variants

The thing to watch out for is the child variants setup, which is how most of the Demo Shop is setup. Commerce treats a product node sitting beneath another product node as a child variant of it, and when it builds the cart name it falls back to the parent for anything missing, which is exactly what’s prepending “Producten” for you. So it’s likely your “Producten” parent is itself a product node (has the Product composition), and “Ram Standaard” is being read as its variant, even though you’ve not defined any variants explicitly. It’s worth checking whether that parent node has the Product composition on it.

I typically set up different document types for simple and variant products so they’re easily distinguished, as you’ll usually need to handle them in different ways (i.e. showing the variant dropdowns and adding them to the basket). Of course, your requirements may vary.

Justin

The parentnode isn’t a product in itself. It’s a different DocType. But behind the scenes, there is some inheritance with some other classes. I think there is something in our code that makes Commerce think the parent node is also a product.

Will take a look at that. As you said, this doesn’t look like a Commerce bug.

Thanks for the info!

Hi @cryothic

Does the parent node have any Umbraco Commerce properties such as SKU or price, etc?

Justin

No, only a couple of toggle-fields for showing up in the navigation and stuff.

My colleague made the base project (derived from the Commerce Demo shop). So I’m not to deep into that part.
But I see:

// Product Overview
public interface IProductGroupPage : IProductGroupComp, IPage { }
public partial class ProductsPage : IProductGroupPage { }

// Products
public interface IProductPage : IProductComp, IProductContentComp, IPage { }
public partial class ProductPage : IProductPage { }
public partial class MultiVariantProductPage : IProductPage { }

I guess Commerce is getting confused somewhere with all the inheritance.