Common Code Snippets
Last updated: April 16, 2026
Hide Price for Specific User Capabilities
add_filter( 'caz_hpp_should_hide_price', function( $should_hide, $product_id, $user_id ) {
// Hide prices for users who do NOT have 'view_wholesale_prices' capability
if ( ! user_can( $user_id, 'view_wholesale_prices' ) ) {
return true;
}
return $should_hide;
}, 10, 3 );
Add Custom Field to Inquiry Form
add_filter( 'caz_hpp_inquiry_fields', function( $fields ) {
$fields['order_quantity'] = array(
'label' => 'Estimated Quantity',
'type' => 'number',
'required' => true,
);
return $fields;
} );
Send Campaign Start Notification to Slack
add_action( 'caz_scm_campaign_activated', function( $campaign_id ) {
$campaign = get_post( $campaign_id );
$webhook = 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL';
wp_remote_post( $webhook, array(
'body' => wp_json_encode( array(
'text' => 'Campaign started: ' . $campaign->post_title,
) ),
'headers' => array( 'Content-Type' => 'application/json' ),
) );
} );
Exclude Products from All Campaigns
add_filter( 'caz_scm_campaign_applies', function( $applies, $product_id, $campaign ) {
// Never apply campaigns to gift cards
$excluded_ids = array( 123, 456, 789 );
if ( in_array( $product_id, $excluded_ids ) ) {
return false;
}
return $applies;
}, 10, 3 );
Was this article helpful?
Thanks for your feedback!