Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cart: fatal errors if not all translations are available #18

Closed
Jon007 opened this issue Jul 6, 2016 · 6 comments
Closed

Cart: fatal errors if not all translations are available #18

Jon007 opened this issue Jul 6, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@Jon007
Copy link

Jon007 commented Jul 6, 2016

Hi, if a customer switches languages on a cart and any of the products are missing there will be a fatal error:
Fatal error: Call to a member function get_permalink() on boolean in ...../wp-content/plugins/woopoly-master/src/Hyyan/WPI/Cart.php on line 140

While this is clearly the fault of the shop owner for not completing the translations, the system should not return fatal errors to the customer, and should continue to show the products in the cart which do have translation.

--- testing on 1.0.0b release ------

@decarvalhoaa decarvalhoaa self-assigned this Jul 6, 2016
@decarvalhoaa
Copy link
Owner

Got it! Thanks. Question: In this scenario (the translation of the product variation doesn't exist) do you think that the Attribute name and value should be translated, or should be kept as in the original language?

@Jon007
Copy link
Author

Jon007 commented Jul 6, 2016

The software should not go ahead and sell the item in a language that the Shop has not provided unless there is some special global setting to enable/disable such behaviour.
Polylang doesn't work in this way, if you request a page that doesn't exist in your selected language you are redirected to the home page for your selected language, you are not offered the page in a different language instead.

If the product is not available for sale in user selected language, ideally:

  1. the product should not be displayed
  2. the user should get a message that some of the products in his cart are not available in selected language
  3. there should be some log or alert so the site administrator can know that this has happened

The software can't guess the reason why the product is not available for sale in that language, there could be different scenarios:

  • the translation may be in Pending Review,
  • it may be deliberate that certain products or category are not available for sale in one language, maybe these products are non-compliant with market requirements or even offensive or illegal for the main country where that language is spoken. Or the site is multi-lingual but not ready to provide customer service and shipping in that language yet.
    Another scenario is a site for export, where the prices include packaging, freight, duties, warehousing for the export market, and it might not be necessary/appropriate to put the items on sale at the same price in the original home country and home country language.

In summary the visibility of the product in the cart should match the visibility of the product on the site.

@Jon007
Copy link
Author

Jon007 commented Jul 8, 2016

Hi, fyi, I managed to get this error on live without switching languages.

If this happens, note the shop manager can't clear the cart,
WooCommerce > System Status > Tools > Customer Sessions - Clear All Sessions
" including any current live carts." doesn't do it: even though the record is deleted from the database, and even if all caching/transients are flushed, the user still has the cart cached in browser cookies, and on refreshing the page, the cart is re-added to wp_woocommerce_sessions and re-triggers the same error page.
To clear the issue the user has to actually delete the cookies - restarting the browser isn't enough.

@decarvalhoaa
Copy link
Owner

Hi Jonathan,
the error without switching the language is likely just the result of an inconsistent status after the error occurred during the language switching.

I have committed on the July, 6th a fix for the issue in the development branch. It will be releases in v1.0.0 release. This release will be available under wordpress.org by the end of the month.

Regarding your feedback to my questions, thank you.
The current behavior is, and I believe is the correct one, if a product was been added in English (example) and the user switch to German, but the product is not translated in German, the English product will be shown in the cart.

The logic to control which product can be sold where, is controlled in WooCommerce. under which countries you sell to and is based on the shipping address (or billing address, for virtual products). It should not depend of the display language.
As a user, I would be quite annoyed if I added a product to the cart and than is removed from the cart because I switch the language. As shop owner, if I sell to the customers country and he wants a product English language but feels more comfortable doing the checkout in German, I'm fine.

My question was not about the product itself, but rather the attribute names and values:

  1. Consider the product title "Awesome Product - English" you added to the card when you browsed the site in English. I have selected to add the Color (attr. name) variation Black (attr. value).
  2. You switch to German, but there is not translation of the product in German. therefore the Cart will show "Awesome Product - English".
  3. In case the Global attribute name and values are translated shall it show Farbe (Color in DE) Schwarz (Back in DE) or Color: Black?

@Jon007
Copy link
Author

Jon007 commented Jul 8, 2016

thanks, in this scenario, if the English version is shown in the cart while switched to German language, then would the user be switched back to English language if the user clicks onto this product?

Normally in the situation that there is no translation in German, Polylang will simply not show the page/post/product or other custom post in German, and redirect to the German home page instead - though showing base language by default could be a desirable option, it's not there for now.

Regarding your question, since the situation is rather invalid either answer is probably ok, however since the product does not exist in German, and the user never selected "Awesome Product - English" "Farbe", it should be fine to show "Awesome Product - English" "Black", which is actually what the user ordered.
On the other hand if there was a Polylang setting for "show everything possible in the target language but fill in with base language if the translation isn't available" then it would be correct to show then colour in German

What about this scenario:

  1. Site base language is English
  2. User is browsing site and adding to cart in French
  3. User switches to German for checkout
  • if there is no German translation, should the cart display show the English version?
  • what if there is no English version in Published status?

@decarvalhoaa
Copy link
Owner

if the English version is shown in the cart while switched to German language, then would the user be switched back to English language if the user clicks onto this product?

Yes, the Product detail page in English will be served to the user.
It would be possible to remove the url from the tumb and title, but I believe that it is best giving the option to the user if we wants, for example, change the attribute selection.

...it should be fine to show "Awesome Product - English" "Black", which is actually what the user ordered.

Ok, my feeling exactly. I will add logic to implement it like so.

What about this scenario:

  1. Site base language is English
  2. User is browsing site and adding to cart in French
  3. User switches to German for checkout
    •if there is no German translation, should the cart display show the English version?

Currently, if a German translation/equivalent is not found, the French translation will be shown. It will shown the one that was added to the card.

•what if there is no English version in Published status?

It will not try the default/base language. If there isn't a translation in the language currently being displayed, it will show the one added to the cart.

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

No branches or pull requests

2 participants