Last active
May 26, 2020 10:45
-
-
Save Balakrishnan-flycart/ea7b8c55d24cb58e9b0320462c0dd569 to your computer and use it in GitHub Desktop.
Discount rules v2: Subscription compatible - Apply discount only for subscription price (excluding sign up fee)
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
if(!function_exists('calculateProductPriceForWooDiscountRules')){ | |
function calculateProductPriceForWooDiscountRules($product_price, $product, $quantity, $cart_item, $calculate_discount_from){ | |
if ($calculate_discount_from == 'regular_price') { | |
if (method_exists($product, 'get_regular_price')) { | |
$product_price = $product->get_regular_price(); | |
} | |
} else { | |
if (method_exists($product, 'get_sale_price')) { | |
$product_price = $product->get_sale_price(); | |
} | |
if(empty($product_price)){ | |
if (method_exists($product, 'get_regular_price')) { | |
$product_price = $product->get_regular_price(); | |
} | |
} | |
} | |
return $product_price; | |
} | |
} | |
add_filter('advanced_woo_discount_rules_product_original_price_on_before_calculate_discount', 'calculateProductPriceForWooDiscountRules', 10, 5); | |
add_filter('advanced_woo_discount_rules_product_price_on_before_calculate_discount', 'calculateProductPriceForWooDiscountRules', 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment