No results found. Try again with different words?

Search must be at least 3 characters.

    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 article helpful?

    Did not find a solution? We are here to help you succeed.

    Related Docs

    Compare Convert Pro with...

    29439
    29440
    Scroll to Top