We are using your B2BKing plugin and have encountered the following situation:
If we set a regular price for a product (in the B2BKing group pricing section), the discount is calculated based on this price, and everything works as expected.
However, if we leave the regular price empty and set only a sale price, this sale price is not used as the active price. Instead, the product still follows the dynamic discount rules and applies group discounts.
Our requirement is:
We need to be able to set a specific lower price or a lower discount for certain products that is not affected by global dynamic discount rules.
We want the price entered at the individual product level to take priority and be applied instead of group discount rules.
Our questions:
Does B2BKing currently offer a way to prioritize individual product pricing over general discount rules?
If yes, where can this be enabled?
If not, is there any way to achieve this through hooks or filters?
It is possible to use a code snippet that will make discount rules ignore products that have a sale price set. This way, your individual product sale prices will take priority over the dynamic discount rules.
Here's the code snippet you can add to your functions.php file or a code snippets plugin:
add_filter('b2bking_applicable_rules_products', 'b2bking_discount_rules_sale_price', 10, 5);
function b2bking_discount_rules_sale_price($results, $rule_type, $product_id, $user_id, $categories_array){
$rules = $results[0];
if ($rule_type == 'discount_everywhere'){
// calculate discount percentage of rule
$sale_price = get_post_meta($product_id,'_sale_price', true);
if (!empty($sale_price)){
$rules = array();
}
}
return array($rules, $results[1]);
}
After adding this snippet, any product that has a sale price will no longer be affected by dynamic discounts.
Please note that this snippet in its current form only looks at the standard WooCommerce sale price field (https://prnt.sc/_B3fJNlqn2JS) and doesn't check B2BKing group sale price fields.
Let me know if you need any clarification or adjustments,
Hello,
We are using your B2BKing plugin and have encountered the following situation:
If we set a regular price for a product (in the B2BKing group pricing section), the discount is calculated based on this price, and everything works as expected.
However, if we leave the regular price empty and set only a sale price, this sale price is not used as the active price. Instead, the product still follows the dynamic discount rules and applies group discounts.
Our requirement is:
We need to be able to set a specific lower price or a lower discount for certain products that is not affected by global dynamic discount rules.
We want the price entered at the individual product level to take priority and be applied instead of group discount rules.
Our questions:
Does B2BKing currently offer a way to prioritize individual product pricing over general discount rules?
If yes, where can this be enabled?
If not, is there any way to achieve this through hooks or filters?
Hi Vladislav,
Thanks for your patience on this,
It is possible to use a code snippet that will make discount rules ignore products that have a sale price set. This way, your individual product sale prices will take priority over the dynamic discount rules.
Here's the code snippet you can add to your functions.php file or a code snippets plugin:
After adding this snippet, any product that has a sale price will no longer be affected by dynamic discounts.
Please note that this snippet in its current form only looks at the standard WooCommerce sale price field (https://prnt.sc/_B3fJNlqn2JS) and doesn't check B2BKing group sale price fields.
Let me know if you need any clarification or adjustments,
Kind regards,
Stefan