/ Documentation /Developers/How to Display a Call-to-action when a Specific Product is Added to the Cart?

How to Display a Call-to-action when a Specific Product is Added to the Cart?

If you want to trigger a call-to-action when a specific product is added to the cart, you just need to add the following code snippet in your theme’s functions.php file.

add_filter( 'cp_pro_target_page_settings', 'cp_is_display_popup', 10, 2 );

function cp_is_display_popup( $display_style, $style_id ) {
     // if style is to display on this page ( replace 7 with your style id ) 
     if( $display_style && 7 == $style_id ) {
         global $woocommerce;
         $display_style = false;
         foreach( $woocommerce->cart->get_cart() as $key => $val ) { 
             $_product = $val['data']; 
             // replace 10 with your product id
             if( 10 == $_product->get_id() ) {
                 // display style
                 $display_style = true;    
             }  
         }  
     }
     return $display_style;
 }
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page

Compare Convert Pro with...

29439
29440
Scroll to Top