diff --git a/facebook-commerce-pixel-event.php b/facebook-commerce-pixel-event.php index 9b4eafde2..ef6899710 100644 --- a/facebook-commerce-pixel-event.php +++ b/facebook-commerce-pixel-event.php @@ -283,11 +283,13 @@ public function get_event_script( $event_name, $params, $method = 'track' ) { * @param string $method Name of the pixel's fbq() function to call. */ public function inject_event( $event_name, $params, $method = 'track' ) { - // If we have add to cart redirect enabled, we must defer the events to render them the next page load. - $should_defer = 'yes' === get_option( 'woocommerce_cart_redirect_after_add', 'no' ); if ( WC_Facebookcommerce_Utils::isWoocommerceIntegration() ) { $code = $this->get_event_code( $event_name, self::build_params( $params, $event_name ), $method ); - if ( $should_defer ) { + + // If we have add to cart redirect enabled, we must defer the AddToCart events to render them the next page load. + $is_redirect = 'yes' === get_option( 'woocommerce_cart_redirect_after_add', 'no' ); + $is_add_to_cart = 'AddToCart' === $event_name; + if ( $is_redirect && $is_add_to_cart ) { WC_Facebookcommerce_Utils::add_deferred_event( $code ); } else { WC_Facebookcommerce_Utils::wc_enqueue_js( $code );