Last active
January 18, 2019 06:51
-
-
Save AshlinRejo/cde6f8957336153cee28b05fe28c3774 to your computer and use it in GitHub Desktop.
Woo Discount Rules: Support WooCommerce Extra Product Options Pro by ThemeHigh
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
if(!function_exists('woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method')){ | |
function woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method($remove_event){ | |
return true; | |
} | |
} | |
add_filter('woo_discount_rules_remove_event_woocommerce_before_calculate_totals', 'woo_discount_rules_remove_event_woocommerce_before_calculate_totals_method'); | |
if(!function_exists('woo_discount_rules_has_price_override_method')){ | |
function woo_discount_rules_has_price_override_method($hasPriceOverride, $product, $on_apply_discount, $cart_item){ | |
if(!empty($cart_item['thwepo_options'])){ | |
return true; | |
} | |
return false; | |
} | |
} | |
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 4); | |
add_filter( 'woo_discount_rules_apply_rules_repeatedly', '__return_true' ); | |
if(!function_exists('woo_discount_rules_skip_discount_for_free_product_method')){ | |
function woo_discount_rules_skip_discount_for_free_product_method($skip_free_product, $cart_item){ | |
$_product = $cart_item['data']; | |
if(!empty($_product)){ | |
$price = $_product->get_price(); | |
if($price == 0){ | |
return true; | |
if(!empty($cart_item['thwepo_options'])){ | |
return true; | |
} | |
} | |
} | |
return $skip_free_product; | |
} | |
} | |
add_filter('woo_discount_rules_skip_discount_for_free_product', 'woo_discount_rules_skip_discount_for_free_product_method', 10, 2); | |
if(!function_exists('woo_discount_rules_do_not_apply_discount_for_free_product_method')){ | |
function woo_discount_rules_continue_before_apply_discount_method($apply_for_free_produc){ | |
return false; | |
} | |
} | |
add_filter('woo_discount_rules_do_not_apply_discount_for_free_product', 'woo_discount_rules_do_not_apply_discount_for_free_product_method', 10); | |
if(!function_exists('woo_discount_rules_reduce_qty_skip_discount_for_free_product_method')){ | |
function woo_discount_rules_reduce_qty_skip_discount_for_free_product_method($reduce_quantity, $cart_item){ | |
$_product = $cart_item['data']; | |
if(!empty($_product)){ | |
$price = $_product->get_price(); | |
if($price == 0){ | |
return $cart_item['quantity']; | |
} | |
} | |
return $reduce_quantity; | |
} | |
} | |
add_filter('woo_discount_rules_reduce_qty_skip_discount_for_free_product', 'woo_discount_rules_reduce_qty_skip_discount_for_free_product_method', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment