Hi,
the reason for your issue is that Pixel Caffeine can’t find the variations of the products in the JS variable that it defines for the AddToCart events.
More specifically, the issue is the file wp-content/plugins/pixel-caffeine/includes/supports/class-aepc-woocommerce-addon-support.php
line 172, inside this code:
public function register_add_to_cart_params() {
global $post;
if ( is_product() ) {
$product = wc_get_product();
} elseif ( ! empty( $post->post_content ) && preg_match( '/\[product_page id=["]?([0-9]+)/', $post->post_content, $matches ) ) {
$product = wc_get_product( get_post( intval( $matches[1] ) ) );
} else {
$product = null;
}
if ( empty( $product ) ) {
return;
}
$args = array();
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
$args[ $product_id ] = AEPC_Track::check_event_parameters( 'AddToCart', array(
'content_type' => 'product',
'content_ids' => array( $this->maybe_sku( $product_id ) ),
'content_category' => AEPC_Pixel_Scripts::content_category_list( $product_id ),
'value' => floatval( $product->get_price() ),
'currency' => get_woocommerce_currency()
) );
foreach ( $product->get_children() as $child_id ) {
$variation = wc_get_product( $child_id );
$variation_id = method_exists( $variation, 'get_id' ) ? $variation->get_id() : $variation->id;
$args[ $variation_id ] = AEPC_Track::check_event_parameters( 'AddToCart', array(
'content_type' => 'product',
'content_ids' => array( $this->maybe_sku( $variation_id ) ),
'content_category' => AEPC_Pixel_Scripts::content_category_list( $product_id ),
'value' => floatval( $variation->get_price() ),
'currency' => get_woocommerce_currency()
) );
}
wp_localize_script( 'aepc-pixel-events', 'aepc_wc_add_to_cart', $args );
}
That $product->get_children()
seems returns an empty array, but it should be filled with the variations of the product and it’s a method of WooCommerce. It should be something related to the configuration of your website because it works very well on my end and I don’t have any other similar case so far.
Please, try to:
– try to flush all caches (do this for every suggestion or everything you do)
– in the previous code, please try to add wp_reset_query();
after `public function register_add_to_cart_params() {
global $post;`
Let me know if they can help you and also if you can debug something more, in order to let me understand more about this issue.
Thank you.