Miscellaneous

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

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!

Join the discussion 3 Comments

Leave a Reply

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

Join the discussion 3 Comments

Leave a Reply