15,000+ Active Stores
4.98 Star Review Average

Tips & Tricks: Make 'Fixed Price' Rules Take Priority Over Discounts

July 15, 2021

By default, if you combine fixed price rules with discount rules, their effects will stack. For example, if you have a product that costs $500 for regular users, and you have 2 rules:

-> fixed price: $250 for B2B users

-> discount: 50% for B2B users

The result is that the price will show as $125, reduced from $250. This works great in many situations, but not all.

There are setups where you may want discounts to not apply to a user if that user already has a fixed price rule.

This can be achieved by adding the following snippet to your site:

add_filter('b2bking_get_offer_product_id', function($offer_id,$current_product_id, $rule_type){

	// if this is a discount rule
	if ($rule_type === 'discount'){
		// if user has any fixed price rules
		$fixed_price_rules = get_transient('b2bking_fixed_price_'.$current_product_id.'_'.get_current_user_id());
		$fixed_price_parent_rules = get_transient('b2bking_fixed_price_parent_'.$current_product_id.'_'.get_current_user_id());

		if (!empty($fixed_price_rules) || !empty($fixed_price_parent_rules)){
			return $current_product_id;
		}
	}

	return $offer_id;
	
}, 10, 3);

Please note that the above currently only works for discount rules that have the "show discount as sale price" checkbox enabled.

B2BKing is a product by Kingtech LLC. We take pride in its active development, dedicated support, and continuous improvement.
  

Buy B2BKing

  

$299 $199

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram