-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add to cart error when "Commerce Product Category Field" points at field with multiple categories #7
Comments
Ah this makes sense, thanks for the report. |
Found another related issue. Might be a bit of an edge case and the simple workaround is for us to add the field to the product type but would be nice if this didn't matter and the plugin just ignored the absence of that field. |
Can you give me a stack trace for these issues @fantasticmachine ? I'm working on a fix, and it'd be helpful. |
Sure. I'll give you a few traces with different circumstances. This one is what I get if a product doesn't have one of the chosen fields in its layout. For instance, we are using a field named "Range" for the Product Commerce Category Field. But we have a product type which didn't have that Range field.
|
If one of the fields set for either Commerce Category or Brand is a Plain Text type field (rather than a category field type) then I see the following error when trying to add the product to the cart.
Sorry, it's not a trace. Just an error in the console as we're adding to the cart via Ajax. |
I also noticed that in some circumstances an option of "none" appears in the select controls for choosing the Commerce Category and Brand fields. However it disappeared when I changed something about the field types/setup. I'm having trouble replicating that now but will keep trying. |
I am just digging into this now Andrew...can I throw in here: For product categories, I use a categories field. Some products appear in multiple categories. Unfortunately Craft doesn't let you order those categories, so it can't necessarily be assumed the first is the 'primary' category as such. For brands, I use an entries filed (not currently selectable at all). In some cases, certain types of products won't have this field of might not have a value (either through something being missed, or because they are an internal product and thus don't have an external brand). I could in theory also add dummy fields to cope with this, but I try and avoid polluting my entries with such things where possible. Would be great if all of that could be factored in - if your are in this & re-jigging anyway! |
Ok, thinking on this more obernight...I think both Product Category and Brand should be Twig mini templates things. The current category stuff that gets to Google is pretty unattractive and hard for business folks to parse (mentally, or in code...) What the business folks want there is really the Eizo Monitors bit, i.e. the deepest category (in our case). others might want just 'Monitors|Eizo' for example. Using a mini twig template here would provide a lot of flexibility in what folks could use/do versus the current approach. Ditto with brand (say What do you think @khalwat @fantasticmachine ? |
Any thoughts on this? I'd really like to add brand data, but can't really do it currently without manually sending events. Twig parsing for these would be very flexible I think? And is in line with how Commerce itself tends to do these things. |
Sounds like this would be a pretty flexible way to do it |
Did anyone come up with a solution for this? We have a product with multiple categories and are experiencing the same error. Here's the stack trace:
|
Fixed in 04a0e16 Set your semVer to: |
So.... is that a no on the twig mini template idea? |
It's not a no. I think parsing it as a string template makes sense; this is just a quick fix |
That did it! Thank you 👍 |
I get the following response error when trying to add to the cart
{"error":"Getting unknown property: craft\commerce\elements\Product::product"}
Have tracked this down to the "Commerce Product Category Field" or "Commerce Product Brand Field" settings to reference a field containing multiple category relationships.
Setting these fields to reference a category field which only allows a single relationship works OK.
Plugin version 1.1.0
The text was updated successfully, but these errors were encountered: