I have a wishlist page which shows all saved products. Products are saved in a cookie and that can be done through a click of a button when viewing a single product.
On that single product, there is an icon with two states, selected or unselected. The purpose is "Save for later". If the specific product is already in the cookie list then i add "selected" class, so the icon changes properly in order to let the user know that he already had "save for later" this product.
An example of cookie with 3 products : 185-589-382
That means we have three products with the ID's 185, 589, 382.
Every product has different ID for each language. That means a product in "EN"(english) has ID 100, but in the other language the ID may be 252.
Example :
Let's suppose i have only one product which has the ID 100 in "EN". That product, in the other language has the ID 200.
When visiting mysite.com/wishlist it shows the product in "EN" (defualt language)
When visiting mysite.com/el/wishlist it shows the product in "GR".
It works just fine even though they have different ID's. (probably because there is a connection between them through the plugin i am using)
My problem
When viewing a single product in "EN", which has the id 100, supposing that id is already in the cookie list - the icon has the selected state. When i press the language switcher, it switches to the other language showing the product but the icon is not in the selected state. I know this happens because in the cookie list i have saved the product with the id 100 (which is in "EN" only) and not 200 which is the other's language ID.
Is there any workaround?
Using WPML Plugin.
- Didn't post any code because i don't have a problem with the coding but if that's going to help you then feel free to ask.
- Currently searching a way to find how these posts are connected so maybe i change what i save into my cookie list. One way would be to save all the id's of each language but i would like to keep it clean - find the best way.