Created
August 21, 2025 11:28
-
-
Save stevygee/2031019c0a7f3a6d07d1c65ad8a3a827 to your computer and use it in GitHub Desktop.
Workaround for compatibility between B2B Market and Discount Rules and Dynamic Pricing for WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Fix discounts not working for guests in cart/checkout | |
* Rules defined in: Discount Rules and Dynamic Pricing for WooCommerce | |
* Disables price rules in: B2B Market | |
*/ | |
function sg_fix_discount_rules_for_guests() { | |
$guest_group = get_option( 'bm_guest_group' ); | |
$customer_group = get_option( 'bm_customer_group' ); | |
$group_id = BM_Conditionals::get_validated_customer_group(); | |
// Disable B2B Market discount rules for guests and customers | |
if ( ! is_user_logged_in() || | |
$group_id === $guest_group || | |
$group_id === $customer_group ) { | |
return true; | |
} | |
return false; | |
} | |
add_filter( 'bm_force_product_price', 'sg_fix_discount_rules_for_guests' ); | |
/* | |
* Disable all B2B Market global or group pricing rules | |
* Keep B2B Market product rules per product intact | |
*/ | |
function sg_disable_b2b_group_pricing_rules( $group_prices ) { | |
$group_prices['global'] = []; | |
$group_prices['group'] = []; | |
return $group_prices; | |
} | |
add_filter( 'bm_group_prices', 'sg_disable_b2b_group_pricing_rules' ); | |
add_filter( 'bm_bulk_prices', 'sg_disable_b2b_group_pricing_rules' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment