Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Cart handling requirements / ideas for discussion #537

Open
Jon007 opened this issue Feb 14, 2021 · 8 comments
Open

Cart handling requirements / ideas for discussion #537

Jon007 opened this issue Feb 14, 2021 · 8 comments

Comments

@Jon007
Copy link
Contributor

Jon007 commented Feb 14, 2021

Cart handling has caused a number of issues and requests to turn it off over the years, because:

  • product translations may not be exactly the same: product itself may be localised such that a different language version is effectively a different product, and even price synchronisation may be turned off so product is priced differently in different languages
  • item added to the cart may be different from underlying product data, as various other plugins implement extended product options etc to the cart item

So there are multiple possible approaches here:

  1. Never change the item in the cart, the cart should always show what the user actually added for the reasons above. If the shopper wants to change the item in the cart or add a different language version they are free to do so.
  2. What the plugin does now, always replace cart items with version in the current language. This works well for the out-of-the box use case with standard products and standard options (where all data is synchronised between product languages, it is the same product).

One relatively easy solution is to make the cart handling a feature option such that the current behaviour can be turned off.
Some cart handling may still be needed though to make sure cart items don't just disappear when when changing language.

Comments/votes welcome.

@dirad
Copy link

dirad commented Feb 23, 2021

My cart shows categories only from default language product, meaning only in that language, while viewing with any language.
Is this relevant to your issue?

I wasnt aware there are standing issues regarding cart, but i am very curious as we soon publish a website with this.

@Jon007
Copy link
Contributor Author

Jon007 commented Feb 23, 2021

@dirad cart is not related to categories, it merely shows cart contents (products) in the correct language. There are no particular standing issues other than some possible compatibility issues with some third party plugins.

@dirad
Copy link

dirad commented Feb 24, 2021

@Jon007 Thanks for replying.
Im am no sure what you mean.. I do show product categories on product pages, and they sync and show up translated as expected. But in cart page the categories show in default lang.
I assume it is because product id in cart is only the one from default language.

Can you point me in the right direction to solve this?

@Jon007
Copy link
Contributor Author

Jon007 commented Feb 24, 2021

@dirad no I can't, I have no idea what you mean, this issue is about products in the cart,
if you have another issue like a category widget you have on the cart page or something like that please raise a separate issue with a lot more details

@Cuniq
Copy link

Cuniq commented Sep 10, 2021

Thank you for breaking this down @Jon007

Imo, the first option is more appealing to me, but with a small change. When the user changes the language the cart should be emptied. Is there any reason that you might need your products in another language? I can think many edge cases that can go bad.

I think we need to drop the current behavior of the plugin in order to reduce the overall complexity. Keeping a 1 to 1 connection between products in different languages is hard. Let alone, polylang is built in order to be able to create two complete different sites with no connection whatsoever.

I am willing to implement this (if we agree on this), but I don't know how polylang changes the locale behind the scenes. I searched for a hook on language change but I didn't find anything. I can dive deeper in the polylang source to find a solution. Any pointers are welcome.

@Jon007
Copy link
Contributor Author

Jon007 commented Sep 12, 2021

Keeping a 1 to 1 connection between products in different languages is hard
maybe but that's kind of the whole point of Polylang or this plugin

polylang is built in order to be able to create two complete different sites with no connection whatsoever.
well no, if there are two complete different sites there is no need to use Polylang

@Cuniq
Copy link

Cuniq commented Sep 12, 2021

I completely agree with both of your statements. I'll try to explain a bit better what I mean.

When I said keeping 1 to 1 connection between languages, I didn't mean programmatically but as an end user. You don't always have the same products for all of your languages (You usually you do, but there are also cases that some people don't want some products in all languages).

Regarding the two separates sites, you are right, I don't know why somebody might do this but he can do that if he wants to. I just gave it as an edge case.

I wrote these examples as the reasoning for my proposal. What do you think about clearing the cart on language change?

@Jon007
Copy link
Contributor Author

Jon007 commented Sep 12, 2021

it could be an option, but I'm not sure what is the use case, it what situation that option is desirable.
I mean, as a shop owner, you normally want customers to order as many products as possible, you normally don't want to confuse customers and make it difficult for them to complete an order by emptying their shopping basket without warning.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants