Hey there!
Sooo I came across an interesting bug today just before deploying a project. I was wondering if I have configured something incorrectly or if this is a bug.
Basically, I have...
* Products (with english titles)
* Product Displays in French / English linking to Products
If I am in the French interface and add a French Product Display and then head over to my cart the title displays in English. Now I believe that's b/c it's actually using the line item title not my product display title. Interesting, the link to the actual product is correct (to the french product!)
I tried changing around the display a bunch of different ways to add more relationships and other things but still scratching my head...
Ideas?
Comment | File | Size | Author |
---|---|---|---|
#15 | fixuntranslatedcartmessage_only_reference.patch | 1.38 KB | 1kubik |
#10 | 2045405-fixuntranslatedcartmessage.patch | 1.34 KB | ShaneOnABike |
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedWhat you've described is expected behavior to me, but I do have a follow-up question: are you translating product titles at all?
The issue here is that the Add to Cart form connects the resultant line item to its display context, which in your case is language specific. I ask the follow-up question, because I don't know if it would actually use a French product title if you were translating to French and the site was being viewed in that language.
Comment #2
ShaneOnABike CreditAttribution: ShaneOnABike commentedYep I have product nodes in both languages which are linked through translations.
Why it's an issue is that at checkout it displays only the English product name (product type) not the referenced product node name (French or English).
Am I missing some reference that should be made cause I don't see how to do this in views. My thoughts on this is the following...
* Users don't care what the internal name is (but we are using that at checkout and in emails sent out)
* Users should see a listing of names based on the language they are in (regardless of internal product name)
Just so I articulated this well..
* Product Node: Title, Body, blah blah
* Product Type: (From store) SKU, Weight, etc
Comment #3
ShaneOnABike CreditAttribution: ShaneOnABike commentedWrong state sorry
Comment #4
ShaneOnABike CreditAttribution: ShaneOnABike commentedWould it not be possible somehow to run each entity through the entity translation functionality? It's not clear to me how to get this working but I might have time to resolve it if given some guidance. But having one language products seems odd... especially in the shopping cart. Since my impression of your work on Commerce was to make it to have a frontend Display so it should just choose the proper language for that I would imagine...
Comment #5
dustinbrunson CreditAttribution: dustinbrunson commentedI am having exact same issue, all translations for product display work great except the title of the product in shopping cart. Has anyone found a solution to the problem?
Comment #6
dustinbrunson CreditAttribution: dustinbrunson commentedActually, I have not been able to find how to add translation to the product itself, only the display product, so when added to shopping cart there is no translation. So how to add translation to product types?
Comment #7
adiatisWe have Commerce products and multiple Products displays (for each language a node).
The title in the shopping cart is not correct for the current language (at the moment the product is added to the cart).
I found function 'commerce_product_line_item_title' in commerce/modules/product_reference/commerce_product_reference.module.
In the 'line_item' object there is a entity reference in [data] [context] [entity]
We have the entity_type and the entity_id. Is it possible to load the title of that entity? This would solve the problem for me. How can I overwrite 'commerce_product_line_item_title'
We have also a problem in 'commerce_cart_rules_add_to_cart_message'. The title of the product is not correct in this function:
The 'product' object has the wrong title. How can we overwrite this function?
Comment #8
ShaneOnABike CreditAttribution: ShaneOnABike commentedWell I have ye to solve the issue with the Rules message... BUT you can change all the views for the cart & order pages include the entity. I used that to display the title rather then the product itself. You'll need the relationship of items that reference the actual entity.
Comment #9
muschpusch CreditAttribution: muschpusch commentedYep i can conform that #8 is working:
You need to set 2 relations:
1.) Set a relation to: (Line Item) Commerce Line item: Product
2.) Commerce Product: Node referencing products from field_product
I needed to disable sql rewrite in query settings too since that one views bug when setting relations between products and product 'nodes'
Comment #10
ShaneOnABike CreditAttribution: ShaneOnABike commentedAlso for the drupal cart message here's a patch for that. Basically it queries the entity for the node id and then from there loads the node to get the title. If this all fails it still uses the product title instead.
I **really** think that this should be applied to the commerce module.
Comment #11
rszrama CreditAttribution: rszrama commentedI could see something like that going in but not as written. We already have in the line item the display context for the product, so there's really no reason to make a blind load of the node like that.
Comment #12
ShaneOnABike CreditAttribution: ShaneOnABike commentedWell I'm all ears if you want to suggest how I could do this different?
READ: A little bit more guidance code wise
Comment #13
ayalas CreditAttribution: ayalas commentedThere are three approaches to tackle this issue (C is the best, in my case).
A) Enable Commerce Backoffice Product, and use content translation for nodes and completely disparate variations per product language.
B) Disable Commerce Backoffice Product (if using Commerce Kickstart at all), so variation types are cancelled and the product type can have "Entity Translation" enabled, as is suggested here.
C) Enable Commerce Backoffice Product with #2203317: Support Entity Translation for Commerce Product and use a single node and Entity Translation enabled variation types. Apply #2203383: Pass user langauge to entity_view() in Rendered product formatter so the rendered product displayed in the "Shoping Car Form" view will get translated. Enable entity translation (field-level translation) for both the product display node and the variation types used. The product reference field should not be translateable.
For approaches A & C:
For A:
As far as I saw, commerce_product_line_item_title() is called but has no effect on the display of the cart, at least not with the Commerce Kickstart default configuration. The title that is eventually displayed in the cart is the product variation's title, through the "Rendered product" formatter. #2203383: Pass user langauge to entity_view() in Rendered product formatter fixes this formatter.
Comment #14
Arne Slabbinck CreditAttribution: Arne Slabbinck commentedPatch #10 helped me out translating the product titles in the 'add to cart' mesage, thanks! (Drupal Commerce 7.x-1.11 / 2015-01-16)
Comment #15
1kubik CreditAttribution: 1kubik commentedHi there!
Thanks for the Patch.
Now a Notice pops up
Notice: Only variables should be passed by reference в функции commerce_cart_rules_add_to_cart_message() (строка 209 в файле /commerce/modules/cart/commerce_cart.rules.inc).
i did a tiny change in the patch to fix this
Comment #16
sabbaghian CreditAttribution: sabbaghian commentedWith Automatic Entity Label module title field in product variation could be customized and also it will be auto-translatable. In my commerce kickstart site, I checked "Automatically generate the label and hide the label field" under "Auto label" tab of my product variation and used [commerce-product:field-product-node:0:title] as Pattern for the title.
In shopping cart form views "Commerce Line Item: Title" is selected for displaying auto-translated title.
By this approach add to cart message is also translated.
Don't forget to uncheck "Auto generate the product title" in field_product of product content type.