Created
November 25, 2021 12:40
-
-
Save AshlinRejo/6255f85994082ad1992509f78d725ca5 to your computer and use it in GitHub Desktop.
Discount rules v2: Woocommerce Custom Product Addons by Acowebs - Apply discount for only base price not for addons
This file contains hidden or 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
global $awdr_addon_commpatible_products; | |
add_filter('advanced_woo_discount_rules_product_price_on_before_calculate_discount', function($product_price, $product, $quantity, $cart_item){ | |
global $awdr_addon_commpatible_products; | |
if(!empty($cart_item)){ | |
if(isset($cart_item) && isset($cart_item['wcpa_data']) && !empty($cart_item['wcpa_data'])){ | |
if (method_exists($product, 'get_id') && function_exists('wc_get_product')) { | |
$product_id = $product->get_id(); | |
if(isset($awdr_addon_commpatible_products[$product_id])){ | |
$product = $awdr_addon_commpatible_products[$product_id]; | |
} else { | |
$awdr_addon_commpatible_products[$product_id] = $product = wc_get_product($product_id); | |
} | |
if (method_exists($product, 'get_price')) { | |
$product_price = $product->get_price(); | |
} | |
} | |
} | |
} | |
return $product_price; | |
}, 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment