• Resolved sachristan

    (@sachristan)


    This doesn’t seem to work at all, we still get daily people with multiple orders after they have received a SyntaxError: Unexpected Token.

    Posted solution below:

    If you see this during checkout for example, it means that a plugin or theme is throwing a notice during the ajax post and breaking the response.

    To find out which plugin is doing this, view your sever error logs and look for notices. Your host may be able to help you look for this log if you cannot locate it.

    To prevent plugins and themes from outputting notices entirely, ensure debug mode is off in your wp-config file:

    define(‘WP_DEBUG’, false);
    error_reporting(0);
    @ini_set(‘display_errors’, 0);

    Can someone point us in the right direction we have customers who are sending in duplicate orders after their initial order has been accepted.

    Thanks

    https://www.ads-software.com/plugins/woocommerce/

Viewing 15 replies - 16 through 30 (of 50 total)
  • Ok, FYI, I just nailed my issue but I have no idea how to fix it.

    Re-reading this thread I openend the Chrome Dev Tools and looked at the XHR requests to see the AJAX calls and saw the same kind of respons as honestaeb AND a much smalled bit of HTML code and text I recognized right away as it’s a notice I added myself via hook.

    In this case, the client sells coffee in 1 lb increments in either 1 or 2 lb bags and I needed to check if any product in cart has 2 units of qty and if so, show the notice.

    My function hooks on the woocommerce_check_cart_items hook. In there I have a conditional check for is_cart() || is_checkout(), inside that another check for quantity and if products are in specific categories then I use the wc_print_notice function to print a message.

    I just tested commenting out that code in my child theme’s functions.php and order went through without error. Here’s my entire code for this below. Any way I could modify that to avoid that error?

    Thanks!

    add_action( 'woocommerce_check_cart_items', 'wfd_two_pounds_bags_warning_check' );
    function wfd_two_pounds_bags_warning_check () {
    	global $woocommerce;
    
    	// Only run in the Cart or Checkout pages
      if( is_cart() || is_checkout() ) {
    
    		$coffee_cats = array( 15, 16, 17, 18, 19 );
    
    		// Loop through the products in the Cart
        foreach( $woocommerce->cart->cart_contents as $product_in_cart ) {
    			if( $product_in_cart['quantity'] >= 2 && has_term( $coffee_cats, 'product_cat', $product_in_cart['product_id'] ) ) {
    				$cart_message = 'Si votre commande contient 2 livres et plus du même café, il sera livré en sacs de 2 livres. Si vous préférez le recevoir en sacs de 1 livre, veuillez le mentionner dans les <strong>notes de la commande</strong> sur la page de commande.';
    
    				if ( '2' == get_current_blog_id() ) {
    					$cart_message = 'If your order contains 2lbs or more of the same coffee, it will be shipped in 2lbs bags. If you prefer to get certain or all of your coffees in 1lbs bags, please mention so in the <strong>Order Notes</strong> on the Checkout page.';
    				}
    
    				wc_print_notice( $cart_message, 'notice');
    				break;
    			}
    		}
    	}
    }

    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.

    Please this system is my way to pay my bills….

    Thank You

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Gebrael read the sticky post and check your gateways are compatible. Don’t post in other users threads – your qu will get buried.

    Hello,

    even with the following fix :

    define('WP_DEBUG', false);
    error_reporting(0);
    @ini_set('display_errors', 0);

    The checkout form is greyed out.

    I’m testing locally with Cheque payment, which is nothing to do with gateway compatibility.
    When I remove the css greying out the form and submit the form I have the same error as everybody :
    SyntaxError: Unexpected Token

    [EDIT]
    I just find out that the problem is only occuring on my local environment. When testing in a production server, the problem is no longer there. Any idea why ? My environments are slightly different but how this problem could be linked to an environment issue ?

    Sorry again but I′m more than 10 days with out any order because of this error, might I change the woocommerce for another pulgin, I need help from plugin author or I will break.

    Thank You

    I have the same issues here. Using the latest WP, Woocommerce and Stripe from Woo. Debug enabled. I get this error even when Stripe is disabled using COD.

    Chrome error-
    SyntaxError: Unexpected Token <

    Firefox Error-
    SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    I had trouble my jewelry earrings site https://cuff.ru

    Chrome: “SyntaxError: Unexpected token < “
    Firefox: “SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data”
    IE: “SyntaxError: Invalid character”
    The problem is on ….\woocommerce\assets\js\fronted\chechout.js
    you have there line 359:

    wc_checkout_form.submit_error( ‘<div class=”woocommerce-error”>’ + errorThrown + ‘</div>’ );

    change too:

    wc_checkout_form.submit_error( ‘<div class=”woocommerce-error”>’ + jqXHR.responseText + errorThrown + ‘</div>’ );

    I hope this will help.

    Thank you for posting a solution kodzero. The problem is that the checkout page uses checkout.min.js and I cannot find that line in the checkout.min.js file…

    I was able to solve the problem, it had nothing to do with the woo commerce code or any official plugins. It was my fault, I had a function hooked to the woocommerce_payment_complete action which was outputting a number. I was able to discover this using the Google Developer tools, looking at the result of the ajax checkout request. I hope this helps.

    Thread Starter sachristan

    (@sachristan)

    This thread just shows how quickly their so called “plugin author” jolley wanted to get as far away from this as possible, totally absolve themselves from responsibility.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    @rob, already told you (all) where the problem will be coming from. I can’t log into your site and debug this for you. If the core gateways work you can be certain where the problem comes from. All woothemes gateways are compatible.

    @mike – not even the generic “pay at pick up” or “Cash/Check” is working though. That also returns the same error. So it can’t be the payment gateways. I’ve disabled all plugins, set it to the default theme and I’m still returning the same error. Ironically I have enabled other popular shopping cart plugins and tested with them and I can get to paypal and process an order no problem. However, my store is already set up in WC and I would really not have to set up a whole new store.

    Thread Starter sachristan

    (@sachristan)

    @mike i wouldn’t expect you to log into my site and debug it, but I would expect woothemes to be more responsive to an obvious problem instead of glossing over it with sarcasm and letting untold souls of supporters left out to flounder with their stores. This problem can sink most sites, ruin store reputations and you need to be more sensitive to that! So how about some help in find a solution. Its obviously not RESOLVED!

    WooThemes & Automattic has to do better.

    @tkieneker we have also reduced our site to a default wootheme and disabled plugins and it still happens.

    I have to agree with @littlebizzy this is a fiasco.

    I had this issue fixed by using the original de-bug code shown at the top and now it has reappeared!

    I tried replacing the info in the wp-config and i am still getting this error.

    now i am getting countless calls and emails about duplicate charges. when will this be corrected??

    I disabled the third party Authorize.net gateway and reinstalled the Woo Version and rather than the SyntaxError I am now getting this message:

    “An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.

    This transaction has been approved.
    It is advisable for you to contact the merchant to verify that you will receive the product or service.”

    Which is what i was getting before and caused me to move to the third party plugin in the first place.

    I need this RESOLVED and i am tired of everytime i have it corrected it reappears.

Viewing 15 replies - 16 through 30 (of 50 total)
  • The topic ‘Common Issue – SyntaxError: Unexpected Token’ is closed to new replies.