Last active
January 24, 2020 10:09
-
-
Save AshlinRejo/46410bb7295afd592ffbd7416be8f3c8 to your computer and use it in GitHub Desktop.
Discount rules: Compatible with Booster for WooCommerce
This file contains 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
/** | |
* 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