szelpe / woocommerce-barion

Barion Payment Gateway for WooCommerce
GNU General Public License v3.0
9 stars 14 forks source link

Theme javascript Window load issue #40

Closed asoka133 closed 4 years ago

asoka133 commented 4 years ago

Hi please change the code in includes/class-wc-gateway-barion-pixel.php to this: (or make a hook to be able to modify to this):

jQuery( window ).load(function() { (function(i,s,o,g,r,a,m){i['BarionAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window, document, 'script', 'https://pixel.barion.com/bp.js', 'bp');

// Send init event
bp('init', 'addBarionPixelId', '{$barion_pixel_id}');

});

Because a slider in our theme waits for the pixel to load 2-3 sec. (Even if the script is async) So we dont want to edit the plugin every time it updates. Thank you!

szelpe commented 4 years ago

Hi asoka, this is called the Barion Pixel, and it's mandatory. Please consider fixing your slider in your theme instead of changing a plugin which is used by 3000+ websites.

There is already hook called woocommerce_barion_disable_tracking for disabling the the Barion Pixel for certain pages, but you should not disable the Barion Pixel globally since it's obligatory for fraud protection: https://www.barion.com/en/support/what-is-a-barion-pixel//

szelpe commented 4 years ago

Also, Barion Pixel shouldn't take seconds to load, maybe something's off, you should contact Barion de v support at devsupport@barion.com address.