Support » Plugin: PW WooCommerce Gift Cards » SyntaxError: Unexpected token C in JSON at position 0

  • Resolved Rob Hamilton

    (@robinhamilton)


    Hi,

    We’ve been using the plugin for a month and all has been working fine.

    However, I recently updated the plugin and WooCommerce. Now, when the user places an order, they receive the following error message:

    ‘SyntaxError: Unexpected token C in JSON at position 0’

    The user receives a confirmation order email but no gift card is generated/sent.

    If I disable the PW Gift Card plugin, this fixes the issue.

    Debugging I’ve tried:

    1. Rollback versions of PW Gift Card and WooCommerce plugins`
    2. Deactivate all other plugins and change to default themes
    3. Re-save permalinks

    Has anyone else had a similar issue?

    Any help is appreciated. If upgrading to the Pro Version will fix the issue then I’m more than happy to do this.

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author pimwick

    (@pimwick)

    I don’t think upgrading to the Pro version would make any difference for an error like this (though there are some great additional features 🙂

    It almost sounds like something is conflicting with the AJAX return data on your server. It’s possible that this error would show more information if you turn on debugging.

    Can you perform the following steps?

    1. Log into your FTP site and edit wp-config.php
    2. Set the following values (add the lines if they don’t exist):

        define( 'WP_DEBUG', true );
        define( 'WP_DEBUG_LOG', true );
        define( 'WP_DEBUG_DISPLAY', false );
        @ini_set( 'display_errors', 0 );

    3. Return to your site and place another order, triggering the error.
    4. Return to wp-config.php and set DEBUG back to false (reverting the changes made in Step 2)
    5. Now go back to FTP and examine the debug log file /wp-content/debug.log

    Rob Hamilton

    (@robinhamilton)

    Thanks for the speedy reply!

    I’ve completed your steps above. Here is the error in debug.log

    [04-Dec-2019 18:34:24 UTC] WordPress database error Cannot add or update a child row: a foreign key constraint fails (robhamil_wp450.wpjo_pimwick_gift_card_activity, CONSTRAINTwp_fk_gift_card_idFOREIGN KEY (pimwick_gift_card_id) REFERENCESwp_pimwick_gift_card(pimwick_gift_card_id)) for query INSERT INTOwpjo_pimwick_gift_card_activity(pimwick_gift_card_id,action,amount,note,user_id,reference_activity_id) VALUES (’49’, ‘create’, NULL, ‘Order 1504 purchased by Robin Hamilton’, 2, NULL) made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action(‘wc_ajax_checkout’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Checkout->process_order_without_payment, WC_Order->payment_complete, WC_Order->save, WC_Order->status_transition, do_action(‘woocommerce_order_status_completed’), WP_Hook->do_action, WP_Hook->apply_filters, PW_Gift_Cards_Purchasing->woocommerce_order_status_completed, PW_Gift_Cards_Purchasing->add_gift_cards_to_order, PW_Gift_Card::create_card, PW_Gift_Card::add_card, PW_Gift_Card->log_activity, PW_Gift_Card_Activity::record

    Plugin Author pimwick

    (@pimwick)

    I received an email with the debug log information.

    This error means that your database user account doesn’t have the correct permissions for creating the gift card tables.

    Send this error message to your website host and let them know that your account needs the “REFERENCES” privilege, even if it’s just temporary (once the tables are created you no longer need the permission).

    Rob Hamilton

    (@robinhamilton)

    My host said they updated the ‘references’ privilege but unfortunately it didn’t work.

    I’ve had to move over to a different plugin. However, many thanks for your quick support, much appreciated!

    Plugin Author pimwick

    (@pimwick)

    Odd, that is the precise error from the plugin. Sorry that they couldn’t help get it installed, best of luck with your store!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.