This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 8 replies, has 2 voices.

Last updated by tomasA-10 2 months ago.

Assigned support staff: Bobby.

Author Posts
August 2, 2019 at 1:43 pm

tomasA-10

I am trying to:Add a product to the cart on the product overview page

Link to a page where the issue can be seen: hidden link

I expected to see:The product being added to the cart after the loading animation has completed.

Instead, I got: The cart is still empty or in the same state as before i pressed the add to cart button.

August 3, 2019 at 12:32 am #4332861

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

i was able to reproduce the issue , if i visit your above link and "add to cart" cart will not be updated.

But if i click on the product, then from within the product i add to cart it works as expected.

how are you currently adding the "add to cart" link within the category page? This is not a woocommerce default link but instead an add to cart with the following link added to it

"hidden link"

I have created a test page testing the link above and it works well outside of the categories page

hidden link

i think the issue here is that the links in the EN version are added as

"<em><u>hidden link</u></em>"

which includes the product-category and the whole directory in it which then just reloads the page and that is why it works outside of the category page

where as in the SV version they are added without the directory (product-category/...)

<em><u>hidden link</u></em>
August 5, 2019 at 7:26 am #4338549

tomasA-10

Yes ofcourse because then i doesnt add it via ajax anymore which i stated was the one that didnt work.
The swedish site is also using the same kind of links on the hidden link page to add products to the cart without a problem.
The english version only works when it is not using ajax and reloading the page.

August 5, 2019 at 5:19 pm #4342193

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

1. How are you adding these buttons with these links ? (the add to cart buttons)

are they added using custom code or a 3rd party plugin ?

2. Go to hidden link and edit the link for "Add to cart" for one of your products (ex. Wall calendar design collection , 1st one) and change it from

<em><u>hidden link</u></em>

to

<em><u>hidden link</u></em>

let me know your results afterwards

August 6, 2019 at 9:04 am #4345593

tomasA-10

Those are added with woocommerce and with the setting WooCommerce > Settings > Products >
Enable AJAX add to cart buttons on archives enabled. If i disable this option everything works as expected. But with the option enabled you just see the loading animation and then when it completes nothing happens. It works on the swedish version but not on the translated english version of the site.

If i change the link for the button in the html of the page to your suggested value the issue still persists.

August 6, 2019 at 8:38 pm #4350453

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

i have test this on a staging environment and it works as expected for all languages

as a test i wanted to validate your different domain by going to WPML->languages->Language URL Format, which returns ""not valid" , additionally when i try to visit the .com product categories now i am being redirected to .se and get a 404

August 7, 2019 at 9:10 am #4353041

tomasA-10

Ok, we have checked so that everything is setup correctly on the webserver and so on for multilanguage with multiple domains and everything should be setup correctly.

Can you give me a link to where you are being redirected to .se and get a 404 ? I can browse the site without any problems.

August 8, 2019 at 12:39 am #4358681

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

It is no longer giving me a 404 error seems to have been a cache issue on my side possibly.

I was able to migrate the site to our cloudways servers to further test it without interfering with your live site.

1. Within my testing environment i am not able to use your different domains per language structure therefore i was forced to use the language url format "language added as parameter"

Results => Ajax call works fine and the products are added to the mini cart, view here
hidden link

2. I did a few more tests and noticed that the Ajax call does indeed get triggered on your live site correctly but the response is not correct and instead of JSON you are receiving HTML source

please try the following

go to hidden link => right click and inspect the page, then select Network (pick XHR) and run the ajax call (click on Add to cart)

then click on the ajax call and review the response , it will be the HTML source

do the same here hidden link or at your default language and you will notice the correct Ajax Response in JSON

3. When using languages in different domains with https, there should be either one SSL certificate for each domain or one certificate that allows multiple domains.

please verify that you have an SSL for both domains or one certificate the allows multiple domains

August 14, 2019 at 8:13 am #4393205

tomasA-10

My issue is resolved now. Thank you!

The problem was not the certificates but a configuration issue on the server where we had made a special solution to be able to have seperate start pages with WPML that caused the issue.