Developer functions

CartBounty provides a collection of functions and methods that developers can use to customize plugin behavior and build integrations with other WordPress plugins and external services. Unlike actions and filters, these functions and methods can be called directly from your own PHP code to perform specific operations. Below you’ll find the available functionality, parameter descriptions and practical examples.

Update customer email and phone consent

Update a customer’s email and/or phone consent for a specific abandoned cart or all existing active abandoned carts associated with their email address. This is particularly useful when integrating CartBounty with external marketing platforms, consent management plugins or custom customer preference systems.

update_cart_consent( $email, $email_consent = null, $phone_consent = null, $cart_id = 0 )
ParameterDescription
$emailCustomer’s email address used to identify abandoned carts.
$email_consenttrue to enable email consent, false to disable it, or null to leave unchanged.
$phone_consenttrue to enable phone consent, false to disable it, or null to leave unchanged.
$cart_idOptional abandoned cart ID. Defaults to 0, which updates all matching active carts.

The example below demonstrates how to disable email consent for all existing active abandoned carts associated with a customer, while leaving phone consent unchanged.

if( class_exists( 'CartBounty_Pro_Admin' ) ){
    $cartbounty = new CartBounty_Pro_Admin( CARTBOUNTY_PRO_PLUGIN_NAME_SLUG, CARTBOUNTY_PRO_VERSION_NUMBER );
    $updated = $cartbounty->update_cart_consent( 'customer@example.com', false );
}

Once CartBounty Pro has been initialized, you can use the following examples to manage different consent preferences.

Disable phone consent only

$cartbounty->update_cart_consent( 'customer@example.com', null, false );

Disable both email and phone consent

$cartbounty->update_cart_consent( 'customer@example.com', false, false );

Enable email consent while disabling phone consent

$cartbounty->update_cart_consent( 'customer@example.com', true, false );

Enable both email and phone consent for a specific cart (ID 123)

$cartbounty->update_cart_consent( 'customer@example.com', true, true, 123 );
Last updated 12 minutes ago

Support

Need premium support for CartBounty Pro?

Please use the button below, reply to your purchase receipt or contact us with e-mail including your license key. This will guarantee a faster response time.

Get Premium support
You were not leaving your cart just like that, right?

Don't Go Just Yet! Claim Your 5% Discount Now! 🥳

Simply provide your email and unlock an instant discount applied to your shopping cart.