Special Shop Page: Only list the products having certain CSP pricing types.

Shortcode to display a special shop page

[csp-products-for-user]

Click for more info.

Because of the different business requirements, you may require some customizations, for example :

  • Only list the products having “User Specific Pricing”.
  • Only list the products having “Role Specific Pricing”.

Etc. While listing the products discounted for the currently logged in user.

This article will explain how to conditionally disable listing the products having certain pricing types.

Hide the products discounted for the user groups.

If a user belongs to some groups but you only want to show the products with the user & role-specific rules on the custom shop page.

you can add the following snippet to your functions.php file.

add_filter('csp_archive_show_product_gsp', 'fnDisableGspForUserShop', 99, 4);
function fnDisableGspForUserShop($status, $userId, $userRoles, $userGroups) {
/* change the value of $status with the help of the parameters & return it.
 * $userId   : Id of the currently logged in user
 * $userRoles: The user roles the currently logged in user belongs to.
 * $userGroups:The user groups assigned to the currenly logged in user.
 * $status : Set this false for the condition where you don't want to show role based pricing. 
 * [ex: $status=false;]
 **/
 return $status;
}

Hide the products discounted for the user roles.

If a user has some user roles but you only want to show the products with the user & group-specific rules on the custom shop page.

you can add the following snippet to your functions.php file.

add_filter('csp_archive_show_product_rsp', 'fnDisableRspForUserShop', 99, 4);
function fnDisableRspForUserShop($status, $userId, $userRoles, $userGroups) {
/* change the value of $status with the help of other three parameters & return it.
 * $userId   : Id of the currently logged in user
 * $userRoles: The user roles the currently logged in user belongs to.
 * $userGroups:The user groups assigned to the currenly logged in user.
 * $status : set this false for the condition where you don't want to show role based pricing.
 * [ex: $status=false;]
 **/
 return $status;
}

Hide the products discounted for a user via user-specific pricing.

If you only want to show the products with the role & group-specific rules on the custom shop page.

you can add the following snippet to your functions.php file.

add_filter('csp_archive_show_product_usp', 'fnDisableUspForUserShop', 99, 4);
function fnDisableUspForUserShop($status, $userId, $userRoles, $userGroups) {
/* change the value of $status with the help of other three parameters & return it.
 * $userId   : Id of the currently logged in user
 * $userRoles: The user roles the currently logged in user belongs to.
 * $userGroups:The user groups assigned to the currenly logged in user.
 * $status : set this false for the condition where you don't want to show role based pricing.
 * [ex: $status=false;]
 **/
 return $status;
}

Similarly, you can combine the above three filters to get the desired results.

Updated on July 1, 2020

Was this article helpful?

Related Articles