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.
1. Customer consent management
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 )
| Parameter | Description |
|---|---|
$email | Customer’s email address used to identify abandoned carts. |
$email_consent | true to enable email consent, false to disable it, or null to leave unchanged. |
$phone_consent | true to enable phone consent, false to disable it, or null to leave unchanged. |
$cart_id | Optional 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 );