WooCommerce Bug Fix: SyntaxError: Unexpected Token (2.4+)

By November 12, 2015Miscellaneous
WordPress Tips and Solutions

Just as a favor to anyone out there that may be experiencing this issue with WooCommerce as of 2.4, I wanted to post the solution that we found. I’m sure this won’t be the end-all solution for everyone, but it may help some of you.

WooCommerce Checkout Not Working Upon Update

Check that your payment gateway isn’t using this method:

$order->payment_complete();

For some reason, using that method had always worked in the past, but now was triggering some non-JSON responses upon checkout. Instead, manually update the stock levels and status like so:


$order->update_status('processing', __( 'Awaiting fulfillment.', 'woocommerce' ));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
WC()->cart->empty_cart();

Hope this saves someone a lot of headache!

Allen Gingrich

Author Allen Gingrich

Allen has worked on the web for over a dozen years. Like many young entrepreneurs, he began with a small workspace in his basement, where he eventually formed Ideas and Pixels. The rest, well, is history. Allen enjoys fine wines, weight training, and beautiful, semantic code.

More posts by Allen Gingrich
  • saba azam

    Earn Free Recharge Anytime Anywhere. Just try free apps and earn unlimited mobile talktime and PayTm cash.

    You can also earn money and PayTm cash by Referring to your Friends. Recharge your mobile instantly.

    https://goo.gl/lhiB47

  • saba azam

    Just download thE EARN MONEY app and recharge your mobile for free…Get upto Rs 250/- per successful referral.

    https://goo.gl/lhiB47

  • mit

    Hi Allen, I’m facing the Woocommerce SyntaxError when I try to checkout by a bank transfer. Where you write the code you put up?
    Thanks in advance