This file contains 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
/** | |
* Get the discount details of given product with custom price | |
* @param $price float/integer | |
* @param $product object (Product object Example: wc_get_product($product_id)) | |
* @param $quantity int | |
* @param $custom_price float/integer (0 for calculate discount from product price) | |
* @param $return_details string (Default value 'discounted_price' accepted values = 'discounted_price','all') | |
* @param $manual_request boolean (Default value false: pass this as true for get discount even if there is no item in cart) | |
* @param $is_cart boolean (Default value true) | |
* @return array|float|int - is product has no discounts, returns $price;else return array of discount details based on $return_details |
This file contains 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
/** | |
* To handle the low price product in set discount. | |
* Works from Discount rules v2.6.1 | |
*/ | |
add_filter('advanced_woo_discount_rules_matched_set_discount_range', function ($selected_bundle_range, $product, $rule, $cart_items, $is_cart){ | |
if(class_exists('\Wdr\App\Helpers\Woocommerce')){ | |
if($is_cart){ | |
if(!empty($selected_bundle_range->type) && $selected_bundle_range->type == 'fixed_set_price'){ | |
if(!empty($cart_items)){ | |
$discounted_price = $selected_bundle_range->value; |
This file contains 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('isPossibleToHaveDiscountThroughWDR')) { | |
function isPossibleToHaveDiscountThroughWDR() { | |
$status = false; | |
if (class_exists('\Wdr\App\Controllers\DiscountCalculator')) { | |
$rules = \Wdr\App\Controllers\DiscountCalculator::$rules; | |
$cart = \Wdr\App\Helpers\Woocommerce::getCart(); | |
foreach ($rules as $rule) { | |
if ($rule->isEnabled()) { | |
if ($rule->hasConditions()) { | |
$conditions_passed = $rule->isCartConditionsPassed($cart); |
This file contains 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 | |
/** | |
* Discount table | |
* | |
* This template can be overridden by copying it to yourtheme/advanced_woo_discount_rules/discount_table.php. | |
* | |
* HOWEVER, on occasion Discount rules will need to update template files and you | |
* (the theme developer) will need to copy the new files to your theme to | |
* maintain compatibility. We try to do this as little as possible, but it does | |
* happen. When this occurs the version of the template file will be bumped and |
This file contains 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 | |
/** | |
* Custom code shortcode | |
* | |
* This template can be overridden by copying it to yourtheme/plugin-folder-name/woo_mail/custom_code.php. | |
* @var $order WooCommerce order | |
* @var $email_id WooCommerce email id (new_order, cancelled_order) | |
* @var $sent_to_admin WooCommerce email send to admin | |
* @var $plain_text WooCommerce email format | |
* @var $email WooCommerce email object |
This file contains 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_discount_prices_of_product', function ($discount_prices, $product, $quantity, $cart_item){ | |
$regular_price = $product->get_regular_price(); | |
$sale_price = $product->get_price(); | |
$default_discount = $regular_price - $sale_price; | |
$non_applied_qty = $discount_prices['discount_lines']['non_applied']['quantity']; | |
if(($default_discount) > 0 && $non_applied_qty > 0){ | |
$discount_prices['initial_price'] = $sale_price; | |
$discount_prices['discounted_price'] = $discount_prices['discounted_price'] - (($default_discount*$non_applied_qty)/$quantity); | |
} |
This file contains 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
function woocommerce_product_get_sale_price_from_woo_discount_rules($value, $product){ | |
if(!is_admin()){ | |
global $flycart_woo_discount_rules; | |
if(!empty($flycart_woo_discount_rules)){ | |
$discounted_price = $flycart_woo_discount_rules->pricingRules->getDiscountPriceOfProduct($product); | |
if($discounted_price !== null){ | |
$value = $discounted_price; | |
} | |
} | |
} |
This file contains 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_scheduled_rebuild_on_sale_index_event_recurrence', function ($recurrence){ | |
$recurrence = 'hourly'; | |
return $recurrence; | |
}, 10, 1); |
This file contains 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_is_conditions_passed', function($result, $rule_object, $rule){ | |
$conditions = $rule_object->getConditions(); | |
$cart = null; | |
if(function_exists('WC')){ | |
$cart = WC()->cart->get_cart(); | |
} | |
if(empty($cart) && !empty($conditions) && count((array)$conditions) == 1) | |
foreach ($conditions as $condition) { | |
$type = isset($condition->type) ? $condition->type : NULL; | |
if($type == 'cart_subtotal' && ($condition->options->operator == 'less_than_or_equal' || $condition->options->operator == 'less_than')){ |
NewerOlder