- How to Install Convert Pro Addons?
- Understanding the General Settings of Convert Pro
- Understanding the Email Notification Settings in Convert Pro
- How to Create a Modal Popup in Convert Pro?
- Configuration Settings for a Modal Popup in Convert Pro
- How to Display a Call-to-action on a Specific Page, Post, Category etc (Page Level Targeting)?
- How to Target Users based on the Device they use?
- Schedule Your Call-to-action in Convert Pro
- What is a Call-to-Action in Convert Pro? How can I create one?
- Shortcut Keys For Customizer Operations
- Google Analytics Integration with Convert Pro
- How to Setup Convert Pro Events in Google Tag Manager
- Understanding the Email Notification Settings in Convert Pro
- How to A/B Test Two or More Call-to-Actions in Convert Pro?
- How to Add Custom CSS/HTML code/shortcode to a Call-to-action in Convert Pro?
- How to Create a Language Specific Popup in Convert Pro?
- Introduction to Rules sets in Launch settings of Convert Pro
- How to Integrate an Elementor Form in a Convert Pro call-to-action?
- How to Disable Click Event for a text?
- What are the Field actions in Convert Pro?
- Designing a Call-to-action in Convert Pro
- Cookie Settings in Convert Pro
- How to Create an Infobar in Convert Pro?
- How to Create a Full Screen Popup or Call-to-action in Convert Pro?
- How to Edit a Call-to-action in Mobile View?
- How can I disable a Call-to-action on Mobile Devices?
- How to Rename a Call-to-action in Convert Pro?
- How to Display a Call-to-action when a Specific Product is Added to the Cart?
- Working with Referrer Detection in Convert Pro
- Show or Hide Call-to-action to Logged in and First time users
- How can I disable a Call-to-action on Mobile Devices?
- How to Disable Google Fonts in the Frontend?
- How to Target Users based on the Device they use?
- Filter to Add a New Custom Font
- Convert Pro Email Notification Filters
- Google Analytics Integration with Convert Pro
- How to Integrate Convert Pro with ActiveCampaign?
- How to Integrate Convert Pro with ConvertKit?
- How to Integrate Convert Pro with AWeber?
- How to Integrate Convert Pro with Benchmark Email?
- How to Integrate Convert Pro with Campaign Monitor?
- How to Integrate Convert Pro with Campayn?
- How to Integrate Convert Pro with CleverReach?
- How to Integrate Convert Pro with Constant Contact?
- How to Add a New Google Font?
- How to Add Custom Conditions to Display a Call-to-action?
- How to Change the Credit Link Text?
- How to Display a Call-to-action when a Specific Product is Added to the Cart?
- How to Trigger a Call-to-action only on Woo-commerce order received page?
- How to Use the Advanced Script Addon in Convert Pro?
- How to Clear Cache for Call-to-Actions in Convert Pro?
- How to Create a Language Specific Popup in Convert Pro?
- How to White Label Convert Pro?
- How to Pass Current Page URL as a Value to Hidden Field of the Form?
- Filter to Add a New Custom Font
- Authenticate your MailChimp Account
- Authenticate your Benchmark Email Account
- Authenticate your ActiveCampaign Account
- Authenticate your Campaign Monitor Account
- Authenticate Your CleverReach Account
- Authenticate Your ConvertKit Account
- Authenticate your GetResponse Account
- Authenticate Your MailerLite Account
- Drip API Token
- How to Trigger a Welcome Popup or Opt-in with Convert Pro?
- How to Trigger an After Scroll Call-to-Action with Convert Pro?
- How to Trigger a Popup when a User is About to Leave the Page (Exit Intent)?
- How to Trigger a Call-to-action only on Woo-commerce order received page?
- How to Trigger a Popup on User Inactivity (User Inactivity Trigger)?
- How to Trigger a Popup or Call-to-action on Click of an Element/Button?
- Trigger a Call-to-Action using a Link Code
- Trigger a Call-to-Action using a Unique CSS class or ID (Button and WordPress Menu Item)
- How to Trigger a Call-to-Action after a Blog Post?
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.
On this page