1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Pro
  4. Developer Documentation

Actions and Filters

WooCommerce Wholesale Pro comes with some filters which allow you to customize the plugin's behavior.

Please note that this code is aimed at developers and if you don't know how to use it then you should ask your developer.

We've partnered with Codeable to provide our customers with expert help if required.

Actions

wcwp_all_import_update_product

Triggered after WP All Import updates a product.

Arguments

  • $post_id (int): The post_id of the product imported.

Example

add_action( 'wcwp_all_import_update_product', 'my_wcwp_all_import_update_product' );
function my_wcwp_all_import_update_product( $post_id ) {
	// your code here...
}

wcwp_category_discount_changed

Triggered after the category discount is changed.

Arguments

  • $role_name (string): The role where discounts where changed.

Example

add_action( 'wcwp_category_discount_changed', 'my_wcwp_category_discount_changed' );
function my_wcwp_category_discount_changed( $role_name ) {
	// your code here...
}

wcwp_created_customer

Triggered after a customer is created following a successful registration.

Arguments

  • $customer_id (int): The user_id of the created customer.
  • $new_customer_data (array): The customer data used to create the customer.

Example

add_action( 'wcwp_created_customer', 'my_wcwp_created_customer', 10, 2 );
function my_wcwp_created_customer( $customer_id, $new_customer_data ) {
	// your code here...
}

wcwp_handle_404

Triggered after a 404 is handled for Public Only protection.

Example

add_action( 'wcwp_handle_404', 'my_wcwp_handle_404' );
function my_wcwp_handle_404() {
	// your code here...
}

wcwp_new_user_auto_approved

Triggered if a new customer is created and auto approved.

Arguments

  • $customer_id (int): The user_id of the customer.

Example

add_action( 'wcwp_new_user_auto_approved', 'my_wcwp_new_user_auto_approved' );
function my_wcwp_new_user_auto_approved( $customer_id ) {
	// your code here...
}

wcwp_new_user_moderation

Triggered if a new customer is created and sent to moderation.

Arguments

  • $customer_id (int): The user_id of the customer.

Example

add_action( 'wcwp_new_user_moderation', 'my_wcwp_new_user_moderation' );
function my_wcwp_new_user_moderation( $customer_id ) {
	// your code here...
}

wcwp_prevent_caching

Triggered after cache prevention is processed on a protected page.

Example

add_action( 'wcwp_prevent_caching', 'my_wcwp_prevent_caching' );
function my_wcwp_prevent_caching() {
	// your code here...
}

wcwp_prevent_caching_login_page

Triggered after cache prevention on wholesale login page.

Example

add_action( 'wcwp_prevent_caching_login_page', 'my_wcwp_prevent_caching_login_page' );
function my_wcwp_prevent_caching_login_page() {
	// your code here...
}

wcwp_prevent_indexing

Triggered after search engine index prevention on protected pages.

Example

add_action( 'wcwp_prevent_indexing', 'my_wcwp_prevent_indexing' );
function my_wcwp_prevent_indexing() {
	// your code here...
}

wcwp_protected_woocommerce_page

Triggered on 'wp' action if protection is enabled.

Example

add_action( 'wcwp_protected_woocommerce_page', 'my_wcwp_protected_woocommerce_page' );
function my_wcwp_protected_woocommerce_page() {
	// your code here...
}

wcwp_register_post

Triggered before a registration is processed or failed.

Arguments

  • $username (string): The username, generated from the email or provided by the user.
  • $email (string): The email address of the user.
  • $errors (\WP_Error): The error collector, if any externally hooked registration processes caused an error.

Example

add_action( 'wcwp_register_post', 'my_wcwp_register_post', 10, 3 );
function my_wcwp_register_post( $username, $email, $errors ) {
	// your code here...
}

wcwp_role_details_updated

Triggered after a Wholesale Role is updated.

Arguments

  • $role_name (string): The name of the role which was updated.
  • $data (array): The new data.

Example

add_action( 'wcwp_role_details_updated', 'my_wcwp_role_details_updated', 10, 2 );
function my_wcwp_role_details_updated( $role_name, $data ) {
	// your code here...
}

wcwp_simple_pricing_changed

Triggered after the simple pricing has changed.

Arguments

  • $role_name (string): The name of the role where pricing changed.
  • $post_id (int): The post_id of the product affected.

Example

add_action( 'wcwp_simple_pricing_changed', 'my_wcwp_simple_pricing_changed', 10, 2 );
function my_wcwp_simple_pricing_changed( $role_name, $post_id ) {
	// your code here...
}

wcwp_update_registration_fields

Triggered when the registration fields are saved.

Example

add_action( 'wcwp_update_registration_fields', 'my_wcwp_update_registration_fields' );
function my_wcwp_update_registration_fields() {
	// your code here...
}

wcwp_user_after_approved

Triggered after a pending customer is approved.

Arguments

  • $user_id (int): The user_id of the approved customer.

Example

add_action( 'wcwp_user_after_approved', 'my_wcwp_user_after_approved' );
function my_wcwp_user_after_approved( $user_id ) {
	// your code here...
}

wcwp_user_before_reject

Triggered after pending customer is rejected, but before deleted.

Arguments

  • $user_id (int): The user_id of the rejected customer.

Example

add_action( 'wcwp_user_before_reject', 'my_wcwp_user_before_reject' );
function my_wcwp_user_before_reject( $user_id ) {
	// your code here...
}

wcwp_variation_pricing_changed

Triggered after the variation pricing is updated.

Arguments

  • $role_name (string): The name of the role where pricing changed.
  • $variation_id (int): The post_id of the variation affected.

Example

add_action( 'wcwp_variation_pricing_changed', 'my_wcwp_variation_pricing_changed', 10, 2 );
function my_wcwp_variation_pricing_changed( $role_name, $variation_id ) {
	// your code here...
}

Filters

wcwp_block_password_reset

Filters whether password resets should be blocked when a user is in moderation.

Arguments

  • $block (bool): Whether to block the password reset. (default: true)

Example

add_filter( 'wcwp_block_password_reset', 'my_wcwp_block_password_reset' );
function my_wcwp_block_password_reset( $block ) {
	// your code to alter $block here...

	return $block;
}

wcwp_calculated_wholesale_price

Filters the calculated wholesale price for a product.

Arguments

  • $price (float): The calculated price.
  • $product (\WC_Product): The WooCommerce product.
  • $wholesale_role (\Barn2\Plugin\WC_Wholesale_Pro\Controller\Wholesale_Role): The wholesale role object.

Example

add_filter( 'wcwp_calculated_wholesale_price', 'my_wcwp_calculated_wholesale_price', 10, 3 );
function my_wcwp_calculated_wholesale_price( $price, $product, $wholesale_role ) {
	// your code to alter $price here...

	return $price;
}

wcwp_category_current_user_allowed_by_role

Filters whether the wholesale user can view the category.

Arguments

  • $allowed (bool): Whether the user is allowed to view. Default is true.
  • $visibility (string): The visibility type.
  • $term_id (int): The term_id of the category.

Example

add_filter( 'wcwp_category_current_user_allowed_by_role', 'my_wcwp_category_current_user_allowed_by_role', 10, 3 );
function my_wcwp_category_current_user_allowed_by_role( $allowed, $visibility, $term_id ) {
	// your code to alter $allowed here...

	return $allowed;
}

wcwp_category_protection_priority_order

Filters the category protection priority.

Arguments

  • $protection_order (string[]): The protections in order of priority. Default is `[ 'wholesale_only', 'public_only' ]`.

Example

add_filter( 'wcwp_category_protection_priority_order', 'my_wcwp_category_protection_priority_order' );
function my_wcwp_category_protection_priority_order( $protection_order ) {
	// your code to alter $protection_order here...

	return $protection_order;
}

wcwp_email_body_content_{$email_id}

Filters the body content of a wholesale email.

Arguments

  • $content (string): The body content.
  • $object (object|bool): The object the email is for (e.g customer).
  • $email (\WC_Email): The email object.

Example

add_filter( 'wcwp_email_body_content_{$this_id}', 'my_wcwp_email_body_content_this_id', 10, 3 );
function my_wcwp_email_body_content_this_id( $content, $object, $email ) {
	// your code to alter $content here...

	return $content;
}

wcwp_enable_wholesale_price_calculation

Filters whether to allow wholesale price calculation on a product.

Arguments

  • $enable (bool): Whether to allow wholesale price calculation on a product.
  • $product (\WC_Product): The product which is being calculated.
  • $user (\WP_User): The user for which the price is being calculated.
  • $price (float): The wholesale price.
  • $cart_item (array|null): The cart item if this is calculated in the cart.

Example

add_filter( 'wcwp_enable_wholesale_price_calculation', 'my_wcwp_enable_wholesale_price_calculation', 10, 5 );
function my_wcwp_enable_wholesale_price_calculation( $enable, $product, $user, $price, $cart_item ) {
	// your code to alter $enable here...

	return $enable;
}

wcwp_login_redirect

Filters the login redirect URL.

Arguments

  • $url (string): The URL to redirect to.
  • $user (\WP_User): The user being redirected.

Example

add_filter( 'wcwp_login_redirect', 'my_wcwp_login_redirect', 10, 2 );
function my_wcwp_login_redirect( $url, $user ) {
	// your code to alter $url here...

	return $url;
}

wcwp_login_shortcode_tag

Filters the login shortcode tag.

Arguments

  • $tag (string): The shortcode tag excluding the brackets.

Example

add_filter( 'wcwp_login_shortcode_tag', 'my_wcwp_login_shortcode_tag' );
function my_wcwp_login_shortcode_tag( $tag ) {
	// your code to alter $tag here...

	return $tag;
}

wcwp_product_id_for_protection_check

Filters the product ID for a category protection check.

Arguments

  • $product_id (int): The product ID.
  • $product (\WC_Product): The WC Product.

Example

add_filter( 'wcwp_product_id_for_protection_check', 'my_wcwp_product_id_for_protection_check', 10, 2 );
function my_wcwp_product_id_for_protection_check( $product_id, $product ) {
	// your code to alter $product_id here...

	return $product_id;
}

wcwp_product_price_transient_key

Filter the transient key name for a generated wholesale price on a product.

Arguments

  • $key (string): The transient key.
  • $product (\WC_Product): The WooCommerce product.
  • $wholesale_role (\Barn2\Plugin\WC_Wholesale_Pro\Controller\Wholesale_Role): The wholesale role object.

Example

add_filter( 'wcwp_product_price_transient_key', 'my_wcwp_product_price_transient_key', 10, 3 );
function my_wcwp_product_price_transient_key( $key, $product, $wholesale_role ) {
	// your code to alter $key here...

	return $key;
}

wcwp_register_shortcode_tag

Filters the register shortcode tag.

Arguments

  • $tag (string): The shortcode tag excluding the brackets.

Example

add_filter( 'wcwp_register_shortcode_tag', 'my_wcwp_register_shortcode_tag' );
function my_wcwp_register_shortcode_tag( $tag ) {
	// your code to alter $tag here...

	return $tag;
}

wcwp_store_query_tax_query

Example

add_filter( 'wcwp_store_query_tax_query', 'my_wcwp_store_query_tax_query' );
function my_wcwp_store_query_tax_query() {
	// your code here...
}

wcwp_widget_get_current_page_url

Filters the current page url with filtering properties.

Arguments

  • $link (string): The calculated url.
  • $widget (\WC_Widget): The widget object.

Example

add_filter( 'wcwp_widget_get_current_page_url', 'my_wcwp_widget_get_current_page_url', 10, 2 );
function my_wcwp_widget_get_current_page_url( $link, $widget ) {
	// your code to alter $link here...

	return $link;
}

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.