Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kowsaliya/627519fd6f51704b781f77033b879dde to your computer and use it in GitHub Desktop.
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
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