Last active
May 19, 2022 12:24
-
-
Save AshlinRejo/74f1a2c231d72200ab120c24c0c7dcd6 to your computer and use it in GitHub Desktop.
Discount rule v2: events document
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
<?php | |
/** | |
* Get discount of a product | |
* @param $product integer|object (Product object Example: wc_get_product($product_id)) | |
* @param $quantity int | |
* @return boolean|float|int - is product has no discounts it returns false | |
*/ | |
$discount = apply_filters('advanced_woo_discount_rules_get_discount_price', $product, $quantity); | |
if($discount !== false){ | |
echo $discount // HERE YOU GET DISCOUNT PRICE | |
} | |
---------------------------------------------------------------------------------------------------------- | |
/** | |
* Get discount of a product from custom price | |
* @param $product integer|object (Product object Example: wc_get_product($product_id)) | |
* @param $quantity int | |
* @param $custom_price int|float | |
* @return boolean|float|int - is product has no discounts it returns false | |
*/ | |
$discount = apply_filters('advanced_woo_discount_rules_get_discount_price', $product, $quantity, $custom_price); | |
if($discount !== false){ | |
echo $discount // HERE YOU GET DISCOUNT PRICE | |
} | |
---------------------------------------------------------------------------------------------------------- | |
Get discount percentage of a product reffer the following snippet | |
https://gist.github.com/AnanthFlycart/6becf99a52ee41f4fa65c362df7d301b | |
---------------------------------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment