It’s your gateway. If you check server error logs it will list notices/warnings etc,
I’ve also seen gateways returning HTML instead of the correct array which again causes this issue.
What payment gateway?
I have the same problem. The code provided above (Placed into wp-config.php) doesn’t suppress this error message on one of my shops. The payment gateway I’m using is Authorize.net AIM (Purchased from Woothemes).
I’ve examined my server error logs, which are not showing any errors. Using the WP Debug (debug.log) is showing me an error for WP Super Cache. Disabling the cache hasn’t resolved the problem.
I’ve examined the AJAX response on my checkout, which begins with the HTML of my admin new order email. After the HTML, I can see the actual AJAX, which looks like:
{“result”:”success”,”redirect”:”https:\/\/www.mysite.com\/checkout\/order-received\/9999?key=wc_order_55ce2544a3486
&utm_nooverride=1″}
4 requests
5.2 KB
4.63s
For now, I’ve been able to keep customers from submitting duplicate orders by placing a message at the top of my checkout page, but obviously I’d like to get this resolved ASAP and remove the message.
We use the same payment gateway premium Authorize.net, we have 5 other woo commerce stores, this is the only one giving us this problem.
We thought about putting a site wide message ourselves but this is becoming a great problem.
@honestaeb Thats the correct response. Can you screenshot that? Was there anything before the first { such as text or white space?
Sure. Here are screenshots of the beginning and ending of the AJAX response:
Beginning of Response
Bottom of Response
It does look like there is a line break at the beginning of the response (And Firefox returns the error: “SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data”). The bottom looks OK, though.
My child theme’s admin-new-order.php appears to be identical to the one provided by WooCommerce (Except I modded mine to include a product thumbnail).
honestaeb it should not be returning the HTML above the response. Thats the error. It should only be returning the JSON at the bottom.
Can you rule out your other plugins quickly, not AIM, and see if they are adding this? I just spoke to Becka from SkyVerge and they have tested AIM again just now without issue.
Found the plugin causing the problem. Unfortunately, it’s a 3rd-party plugin, so I’m following up with that developer to get a solution. Thanks for your help!!
Which one, so we all know?
The plugin is Vendor Stores from Ignitewoo.com
That’s a bit odd – we have no reports of similar behavior. But we’re willing to have a close look and help find out why this happens. I see that you’ve contacted us directly, so we’ll be in touch via email 🙂
For those still following this error, yes, the new WooCommerce update “caused” this with some radical code changes. Woo is blaming various payment gateways, however, WC should probably have kept their code more compatible with existing gateways (or worked with plugin authors to prepare for such a radical change in code).
http://www.woothemes.com/2015/08/woocommerce-2-4-release/#comment-2074447
Vendor Stores
PayPal for WooCommerce
WooCommerce PayPal Standard (Multi Account)
Aelia Currency Switcher for WooCommerce
… among other payment gateway plugins are showing this Syntax error.
https://wordpress.org/support/topic/24-common-issue-syntaxerror-unexpected-token
The official “fix” by WooCommerce (above link) is merely to disable error reporting in WordPress and check your server logs to see which gateway payment plugin is throwing errors on your server (not really a fix at all). You will probably need to contact the author of your gateway plugin and/or pray for a WooCommerce update soon that is more compatible with the dozens of gateway plugins out there.
In our case, no error was being shown in server logs, so there is truly no easy way to diagnose this for most webmasters.
Overall a disappointing WC release, and the first major release since Automattic took over WooThemes. Many UI errors being reported as well. But WC has an amazing team so let’s hope they learn a lot from the 2.4 nightmares and incorporate those lessons into future development. Cheers!
@littlebizzy The only change here is enforcing valid JSON rather than allowing any response. Any output from a plugin, be that a notice, warning, or echoing of HTML, will break this valid JSON response.
In the call for beta testers, and prompts for developers to test code, no reports came in about the above, no one asked that it change, no Woo gateways broke.
If by compatible you mean more forgiving of errors, fine, but thats not a great solution either 🙂
This issue was never resolved, we are still getting these errors with no solution from woo commerce and every plugin developer saying that its woocommerce not their plugin. This blame game can go all day if thats their positions. This issue has not been resolved by any stretch of the imagination.
Hello, again and sorry for my English.
I have that problem too
SyntaxError: Unexpected token
Pls fix that bug next release.
Another many people have problem too http://www.kriesi.at/support/topic/woocommerce-update-breaks-checkout-syntaxerror-unexpected-token/
Exact same problem here:
SyntaxError: Unexpected token <
Disabled all plugins but WooCommerce on my local copy, changed theme to TwentyTwelve, added the above code in wp-config. Nothing works. Still getting that error.