Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Discount rules: Compatible with Booster for WooCommerce
/**
* Compatible with booster plugin https://booster.io/shop/booster-for-woocommerce-plus-plugin/
*
* Limitations:
* Works only for Fixed option for Per product settings in Booster settings
* */
add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules', 10, 2);
function wcj_price_by_user_role_get_price_compatible_with_discount_rules($return, $_product){
remove_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules', 10, 2);
global $flycart_woo_discount_rules;
if(!empty($flycart_woo_discount_rules)){
$discountPrice = $flycart_woo_discount_rules->pricingRules->getDiscountPriceOfProduct($_product);
if($discountPrice !== null){
$return = $discountPrice;
}
}
add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules', 10, 2);
return $return;
}
add_action('woocommerce_before_calculate_totals', function (){
remove_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules', 10, 2);
}, 999);
add_action('woocommerce_before_calculate_totals', function (){
add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules', 10, 2);
}, 1001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.