Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshlinRejo/e279d8cbf6b361b98b2b2628c5b0aec1 to your computer and use it in GitHub Desktop.
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
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