#185 – Sorry, there was a problem posting your comment.

Posted in ‘weeblrAMP’
This is a public ticket. Everybody will be able to see its contents. Only enter usernames, passwords or any other sensitive information in the Private information field.
Friday, 29 November 2019 22:28 UTC
flashwebcenter
 Thank you for your help with the reviews. I am testing the work locally and on the server. On my local I can post a comment or add a product to cart. But on the live site I can't add a product to cart or post a comment. My local and live have valid AMP pages. I checked the error in Console, the error was Failed to load resource: the server responded with a status of 406 (). I started debugging by installing a fresh wordpress on a new domain and new directory live. I installed woocommerce and weeblramp and weeblr woocommerce only. I am still getting the same error. I thought maybe you'd had this issue in the past or something similar. I appreciate your help.
Saturday, 30 November 2019 00:34 UTC
flashwebcenter
I did some debugging by deactivating weeblramp and installing different amp plugin better amp. https://wordpress.org/plugins/better-amp.
I was able to add to cart and even view cart with AMP pages. It looks like the problem is not from my server or any other additional plugins. I think it is related to this https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cors-requests/
Monday, 02 December 2019 05:14 UTC
flashwebcenter
I had an issue with the reviews. Some were showing and some were not. I had to dig more and I found that you are checking the type in wc_single_reviews.php template for comment or review. So I tried to override the template and it was not working. When you disable the theme in the settings Disable theme on AMP pages you can't override the default templates.
Monday, 02 December 2019 09:39 UTC
wb_weeblrpress
Hi

It looks like the problem is not from my server or any other additional plugins
Well if you can make it work normally from localhost and it stops working when you move it online, there certainly is a relationship with the server setup. I have not seen this issue before and commenting/reviewing and adding to cart works normally as of today on all our testing sites (I just tested again to be sure).

. I think it is related to this https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cors-requests/
CORS are properly handled where they need to. That's why with weeblrAMP you can add to cart or comment even when the page is on Google or Twitter servers, not on your own domain.
Most importantly, a CORS issue would give you a clear "CORS" error message, not a 406 response code.

I did some debugging by deactivating weeblramp and installing different amp plugin better amp. https://wordpress.org/plugins/better-amp.

I was able to add to cart and even view cart with AMP pages.
That's quite possible but it entirely depends on how they perform the add to cart. Is this by staying AMP for instance?

So I tried to override the template and it was not working
How did you try to override that template? where did you put your overrides? Have you read the override documentation on this page?

When you disable the theme in the settings Disable theme on AMP pages you can't override the default templates.
Remember that at no time your theme is used for rendering the page. The templates in your theme are not used and they certainly cannot be overriden usually.

The override thing is a separate concern, we first need to tackle the reviewing process.

For all of these, questions, the absolute 1st step is to provide me with full and real URLs: a page where you tried to add to cart, a page where reviews are missing, etc
And probably backend access so that I can enable/disable things.

Best regards

 
Monday, 02 December 2019 14:51 UTC
flashwebcenter
I created an admin user in the website. This is a testing website. After we get the add to cart work, I will create a new db.
Monday, 02 December 2019 17:28 UTC
wb_weeblrpress
Hi

I looked around but it defintely look like a server setup issue. I enabled back the other AMP public and indeed they are using another method: instead of doing an ajax request to add to cart, they just reload the entire page so basically there's no ajax needed and they do not hit that problem. Problem with their method is that it likely won't work when the page is seen from Google cache servers (that is: when in search results).

I did some googling for this kind of issue and possible related issues mention:

- firewall or mod_security blocking requests to the server
- the request type we use is "multipart/form-data"

By comparison, WooCommerce itself uses ajax requests "application/x-www-form-urlencoded"

Both "multipart/form-data" and "application/x-www-form-urlencoded" are perfectly valid and legal, but it seems your server is only accepting the latter.

I would suggest you check out your server or talk to your hosting company and see if that ring any bell (it should). In the mean time, I'll look at adding a filter to be able to modify this.

Best regards
 
Monday, 02 December 2019 17:44 UTC
wb_weeblrpress
Hi

After further research, I found out that this cannot be changed as the ajax request is made directly by the AMP runtime, andAMP only supports multipart/form-data. So the only way to perform an ajax "Add to cart" or any kind ajax form operation is for the server to support "multipart/form-data" forms.
Note that multipart/form-data is also required for uploads as well.

I'm not yet 100% sure this is the reason of this problem but considering both WooCommerce uses application/x-www-form-urlencoded" and Better AMP does not use ajax at all, and those are the only difference I could see in the way, I would thing the solution is indeed in the server setup.
This is also strongly confirmed by the fact all works on your local machine.

Best regards
 
Monday, 02 December 2019 19:45 UTC
flashwebcenter
Hello,
Thank you for your work and search. I googled more trying to understand the problem difference between multipart/form-data and application/x-www-form-urlencoded https://gist.github.com/joyrexus/524c7e811e4abf9afe56.
I also wanted to know if my server configuration has a problem. I installed the plugin https://wordpress.org/plugins/woo-ajax-add-to-cart. It worked fine with regular html pages. I guess wordpress and this plugin use application/x-www-form-urlencoded. Unfortunately, I will not be able to use this plugin if there is no work around this issue.
Tuesday, 03 December 2019 07:54 UTC
wb_weeblrpress
Hi

I also wanted to know if my server configuration has a problem.
It most likely does.

I installed the plugin https://wordpress.org/plugins/woo-ajax-add-to-cart. It worked fine with regular html pages. I guess wordpress and this plugin use application/x-www-form-urlencoded.
You do not need a plugin, WooCommerce uses ajax itself for adding to cart from regular pages. And you can check that by yourself by using the developer tools in your browser:



Unfortunately, I will not be able to use this plugin if there is no work around this issue.
Totally fine, we'll refund you. Note that if you subscribed with Paypal, you will need to cancel the recurring subscription payment from your Paypal dashboard. If you registered with a credit card, we can refund and cancel subscription ourselves.

Unfortunately, I will not be able to use this plugin if there is no work around this issue.
Please note that you should ask your hosting company or developer to fix the problem. This will come back to bite you because multipart/form-data is required for some operations. Likewise, all ajax operation with AMP are done with multipart/form-data so at some point you will hit a limit on what you can do with your store. Be sure to test all operations before committing to another AMP plugin.

Please confirm you want to be refunded of your purchase.

Best regards
 
Tuesday, 03 December 2019 14:53 UTC
flashwebcenter
Hello,
Thank you for your help. I have been looking around for almost a week testing other plugins. I like this plugin and I am not giving up on it. I contacted my hosting company and they said the issue I have is due to mod security rules. They said I have to wait 24-48 hours.

I will update with you later.

Tuesday, 03 December 2019 17:38 UTC
wb_weeblrpress
Hi

I like this plugin and I am not giving up on it
Happy to hear that, I know how frustrating it can be to test many plugins and have all requirements be met!

I contacted my hosting company and they said the issue I have is due to mod security rules. They said I have to wait 24-48 hours.
My reading tells me that as well. Glad they can reconfigure the server for that.

I will leave this ticket open in case you need to add something. It will automatically close in 2 weeks if no further comment is made.

Cheers

 
Wednesday, 04 December 2019 04:49 UTC
flashwebcenter
They were able to fix the issue. Thank you very much.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.