Along with the customization options available in plugin settings, CartBounty also allows the use of different hooks for advanced customization. These hooks are an excellent way if you are looking to alter or extend the features of CartBounty without modifying the core files of the plugin.
Below you will find a list of hooks available in CartBounty alongside different examples. When using these actions and filters to modify the plugin, please add your code in the functions.php file of your theme.
General hooks
Filters:
- cartbounty_from_email
- cartbounty_waiting_time
- cartbounty_include_tax
- cartbounty_price_format
- cartbounty_display_currency_code
- cartbounty_save_custom_fields
- cartbounty_custom_email_selectors
- cartbounty_custom_phone_selectors
- cartbounty_custom_add_to_cart_button_selectors
- cartbounty_phone_validation
- cartbounty_disable_input_bot_test
- cartbounty_restore_classic_checkout
- cartbounty_restore_block_checkout
- cartbounty_cart_cooldown_period
- cartbounty_cart_ip_cooldown_period
Here is an example how to change the From email that sends out notification emails using “cartbounty_from_email” filter. Please add it to your theme’s functions.php file:
function change_from_email( $html ){ return '[email protected]'; } add_filter( 'cartbounty_from_email', 'change_from_email' );
Example how to customize default waiting time after which the cart is considered abandoned using “cartbounty_waiting_time” filter from 60 minutes (default time) to 30 minutes. Add it to your theme’s functions.php file:
function change_waiting_time( $minutes ){ return 30; //Minimum allowed time is 20 minutes } add_filter( 'cartbounty_waiting_time', 'change_waiting_time' );
Example how to display abandoned cart product prices excluding taxes:
add_filter( 'cartbounty_include_tax', '__return_false' );
Exit Intent hooks
Exit Intent template contains different actions and filters that allow you to create new, edit, replace, or remove existing content including the main image in Exit Intent window.
Actions:
- cartbounty_exit_intent_start
- cartbounty_exit_intent_after_title
- cartbounty_exit_intent_before_form_fields
- cartbounty_exit_intent_end
Filters:
- cartbounty_exit_intent_close_html
- cartbounty_exit_intent_image_html
- cartbounty_exit_intent_title_html
- cartbounty_exit_intent_description_html
- cartbounty_exit_intent_field_html
- cartbounty_exit_intent_button_html
Here is an example how to add additional subtitle after the main title using our “cartbounty_exit_intent_after_title” action hook. Please add it to your theme’s functions.php file:
function add_extra_html_after_title() { echo "<p>Additional subtitle here...</p>"; } add_action('cartbounty_exit_intent_after_title', 'add_extra_html_after_title' );
Example how to change the main image using a filter:
function modify_image( $html ){ return '<img src="http://www.link-to-your-custom-image-here..."/>'; } add_filter( 'cartbounty_exit_intent_image_html', 'modify_image' );
Example how to change the main title using a filter:
function modify_title( $html ) { $custom_title = 'Your text here...'; return preg_replace('#(<h2[^>]*>).*?(</h2>)#', "$1 $custom_title $2", $html); } add_filter( 'cartbounty_exit_intent_title_html', 'modify_title' );
Example how to change the description using a filter:
function modify_description( $html ){ $custom_description = 'New description here...'; return preg_replace('#(<p[^>]*>).*?(</p>)#', "$1 $custom_description $2", $html); } add_filter( 'cartbounty_exit_intent_description_html', 'modify_description' );
WordPress email hooks
WordPress abandoned cart reminder template uses multiple actions and filters which can be used to alter the contents an appearance of the email.
Actions:
- cartbounty_automation_before_title
- cartbounty_automation_after_title
- cartbounty_automation_after_intro
- cartbounty_automation_after_button
- cartbounty_automation_footer_start
- cartbounty_automation_footer_end
Filters:
- cartbounty_automation_title_html
- cartbounty_automation_intro_html
- cartbounty_automation_button_html
- cartbounty_automation_copyright
- cartbounty_automation_footer_address_1
- cartbounty_automation_footer_address_2
- cartbounty_automation_unsubscribe_html
- cartbounty_wordpress_batch_email_limit
Example how to add additional content right before the main title in WordPress recovery reminder email:
function cartbounty_automation_add_extra_title(){ esc_html_e( 'Additional content before main title', 'woo-save-abandoned-carts' ); } add_action( 'cartbounty_automation_before_title', 'cartbounty_automation_add_extra_title' );
An example how to use a filter to alter the main title:
function cartbounty_alter_automation_title( $title ){ return '<h1 style="font-size: 60px; padding-bottom: 30px;">'. __('My new title', 'woo-save-abandoned-carts') .'</h1>'; } add_filter( 'cartbounty_automation_title_html', 'cartbounty_alter_automation_title' );
Example how to replace existing button name from “Complete checkout” to “Return to cart”:
function cartbounty_alter_automation_button( $button_html, $args ) { $new_text = __( 'Return to cart', 'woo-save-abandoned-carts' ); // Modify the button text $button_html = sprintf( '<a href="%1$s" title="%4$s" style="margin: 0; outline: none; padding: 0; box-shadow: none;"> <span style="padding: 18px 35px; background-color: %3$s; border-radius: 4px; color: %2$s; font-family: \'Open Sans\', Roboto, \'San Francisco\', Arial, Helvetica, sans-serif; display:inline-block; border: 0px none; font-size: 17px; font-weight: bold; line-height: 1; letter-spacing: normal; text-align: center; text-decoration: none; outline: none;">%4$s</span> </a>', esc_url( $args['recovery_link'] ), esc_attr( $args['main_color'] ), esc_attr( $args['button_color'] ), esc_html( $new_text ) ); return $button_html; } add_filter( 'cartbounty_automation_button_html', 'cartbounty_alter_automation_button', 10, 2 );
How to change the default footer address. By default, it is taken from WooCommerce store address you have entered, but you can change it using a filter:
function cartbounty_alter_automation_footer_address_1( $address ){ esc_html_e('First address line...', 'woo-save-abandoned-carts'); } add_filter( 'cartbounty_automation_footer_address_1', 'cartbounty_alter_automation_footer_address_1' ); function cartbounty_alter_automation_footer_address_2( $address ){ esc_html_e('Second address line...', 'woo-save-abandoned-carts'); } add_filter( 'cartbounty_automation_footer_address_2', 'cartbounty_alter_automation_footer_address_2' );