Remove ClearPay Messaging if user has role ‘wholesale’
-
My site has both trade customers and wholesale customers. When a customer is logged on as a wholesale customer I need to remove all ClearPay messaging on Product pages. I have tries hooking into ‘clearpay_is_product_supported’ but all this does is return a message ‘ClearPay is not available for purchasing this item’ I would like to remove the ClearPay message altogether.
// Hook into the 'clearpay_is_product_supported' filter
add_filter( 'clearpay_is_product_supported', 'disable_clearpay_for_wholesale_users', 10, 2 );
function disable_clearpay_for_wholesale_users( $is_supported, $product ) {
// Get the current user
$current_user = wp_get_current_user();
// Check if the current user has the 'wholesale' role
if ( in_array( 'wholesale', (array) $current_user->roles ) ) {
// Set to false to disable Clearpay for wholesale users
$is_supported = false;
}
return $is_supported;
}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.