WooCommerce exclude sale price per user role (3 posts)

  1. zink
    Posted 2 years ago #

    I'm using WooCommerce and the Dynamic Pricing extension. I've set pricing discounts for 2 user roles, Dealers and Distributers. Currently, if I set a sale price on a product, the sale price is reflected for all users, and the discount for Dealers and Distributors is then compounded on top of it.

    How would I conditionally state that if the user is a Dealer or Distributor, remove the sale price but still apply the price discount that's set in Dynamic Pricing?

    Thanks for any help.


  2. thedeancorp
    Posted 1 year ago #

    Were you able to figure this out? I am running into this exact same issue.

  3. zink
    Posted 1 year ago #

    Give this a shot. Add it to your functions file. Adding the role names to current_user_can() worked, but the WP docs warned that it may not.

    // Remove Sales Flash if Dealer/Distributor/Reseller
    if ( current_user_can('dealer') || current_user_can('distributor') || current_user_can('reseller')) {
    	add_filter('woocommerce_sale_flash', 'woo_custom_hide_sales_flash');
    	function woo_custom_hide_sales_flash() {
    	    return false;

Topic Closed

This topic has been closed to new replies.

About this Topic