Created
October 13, 2022 11:53
-
-
Save AshlinRejo/e279d8cbf6b361b98b2b2628c5b0aec1 to your computer and use it in GitHub Desktop.
Discount rules v2: Get discount price of product without considering cart item quantity
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
add_filter('advanced_woo_discount_rules_cart_item_quantity', function ($cart_item_quantity){ | |
global $awdr_temp_qty_cal; | |
if($awdr_temp_qty_cal === true) $cart_item_quantity = 0; | |
return $cart_item_quantity; | |
}); | |
add_action('woocommerce_before_add_to_cart_form', function (){ | |
global $awdr_temp_qty_cal; | |
$awdr_temp_qty_cal = true; | |
global $product; | |
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', 0, $product, 1, $product->get_price(), 'discounted_price', true, false); | |
if($discount !== false){ | |
//$discount -> Here we get discount amount | |
} | |
$awdr_temp_qty_cal = false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment