Created
February 21, 2020 08:25
-
-
Save Kowsaliya/627519fd6f51704b781f77033b879dde to your computer and use it in GitHub Desktop.
Woo Discount Rules: For applying discount on base price and add on price main while using Woocommerce product addon
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('woo_discount_rules_has_price_override_method')){ | |
function woo_discount_rules_has_price_override_method($has_price_override, $product, $on_apply_discount){ | |
return true; | |
} | |
} | |
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 3); | |
function woo_discount_rules_price_rule_final_amount_applied_method($discountedPrice, $price, $discount, $additionalDetails, $product, $product_page){ | |
if($discountedPrice < 0) $discountedPrice = 0; | |
$total_price = $product->get_price(); | |
$addon_price = 0; | |
if($price != $total_price){ | |
$addon_price = $total_price - $price; | |
} | |
$discountedPrice = $discountedPrice + $addon_price; | |
return $discountedPrice; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment