• Resolved Josh Kohlbach

    (@jkohlbach)


    Hey guys,

    Getting a fatal error here on a call to get_sku(). This is showing up on a number of pages throughout my site. It’s preventing any tracking getting through at all.

    Only seems to show up for non-logged in users.

    Fatal error: Uncaught Error: Call to a member function get_sku() on null in /***/wp-content/plugins/woocommerce-google-analytics-integration/includes/class-wc-google-analytics-js.php:445 Stack trace: #0 /***/wp-content/plugins/woocommerce-google-analytics-integration/includes/class-wc-google-analytics.php(484): WC_Google_Analytics_JS->product_detail(NULL) #1 /***/wp-includes/plugin.php(525): WC_Google_Analytics->product_detail(”) #2 /***/wp-content/themes/wws/page-bundle-temp.php(136): do_action(‘woocommerce_aft…’) #3 /***/wp-includes/template-loader.php(89): include(‘/***…’) #4 /***/wp-blog-header.php(16): require_once(‘/***…’) #5 /***/index. in /***/wp-content/plugins/woocommerce-google-analytics-integration/includes/class-wc-google-analytics-js.php on line 445

    On the latest WooCommerce (2.5.2), Integration plugin (1.4.0) and WP (4.4.2) as of writing

    Let me know if you need any more info! Appreciate any info your team can provide on tracking this issue down…

    Cheers,
    Josh

    https://www.ads-software.com/plugins/woocommerce-google-analytics-integration/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Josh Kohlbach

    (@jkohlbach)

    Any ideas?

    Anyone from WooThemes want to weigh in on this?

    If I don’t hear back I’ll be forced to and maybe switch plugins or find some other way to add the tracking.

    It was working fine up until the latest WooCommerce release…

    Cheers,
    Josh

    Came across the same problem and turning off tracking of Add to Cart Events seems to get rid of it.

    Two questions I guess:
    1. Do the products in question actually have SKUs?
    2. Is this happening on product pages (product, product category) or non product pages (static things like about us, etc.)

    The line in question is:
    'id': '" . esc_js( $product->get_sku() ? $product->get_sku() : $product->id ) . "',

    Which basically says give me the sku for product on this page (so a product detail page), and if you can’t get me the sku, get me the post_id. If you don’t care you could just replace the whole thing with 0 (e.g. esc_js( ‘0’ )).

    Actually in retrospect, don’t do that. It’ll lump all your sales in Google Analytics under one SKU(‘0’). You’d be better off deleting/commenting out the line if you can’t get it to work.

    Thread Starter Josh Kohlbach

    (@jkohlbach)

    In my situation my products had SKUs and this code was previously working on earlier versions.

    Honestly, I gave up on this plugin a long time ago. After several attempts at reaching out, it appears to be unmaintained which is a shame.

    I’m now using MonsterInsights e-Commerce Tracking and it’s much more reliable. Worth paying for.

    Cheers,
    Josh

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fatal error get_sku()’ is closed to new replies.