1. Home
  2. Abandoned Cart for WooCommerce – Lite
  3. Hooks & Filter documentation
  4. Hooks for cart capture

Hooks for cart capture

How can I restrict registered user’s cart from being captured?

Hook
wcal_restrict_user

/**
* Add this code snippet in the "functions.php" file of your currently active theme.
*/
add_filter( 'wcal_restrict_user', 'restrict_admin_carts', 10, 2 );

function restrict_admin_carts( $restrict, $user_id ) {
$user_meta  = get_userdata( $user_id );
$user_roles = $user_meta->roles;

if( in_array( 'administrator', $user_roles ) ) {
$restrict = true;
}
return $restrict;
}
Was this article helpful to you? Yes No

How can we help?