Version Description
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.4.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.4 to 1.4.5
- includes/cart-rules.php +76 -14
- includes/pricing-rules.php +13 -4
- readme.txt +1 -1
- woo-discount-rules.php +1 -1
includes/cart-rules.php
CHANGED
@@ -536,24 +536,86 @@ if (!class_exists('woo_dicount_rules_cartRules')) {
|
|
536 |
$discount = 0;
|
537 |
$discounts = array();
|
538 |
if (!isset($this->rule_sets)) return false;
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
} else {
|
548 |
-
//
|
549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
550 |
}
|
551 |
-
// Sum of Available discount list.
|
552 |
-
$discount += $discounts['to_discount'][$index];
|
553 |
-
// Update the status of the status of the discount rule.
|
554 |
-
$discounts['is_enabled'][$index] = $rule['enabled'];
|
555 |
}
|
556 |
}
|
|
|
557 |
$this->discount_total = $discount;
|
558 |
return $discounts;
|
559 |
}
|
536 |
$discount = 0;
|
537 |
$discounts = array();
|
538 |
if (!isset($this->rule_sets)) return false;
|
539 |
+
|
540 |
+
// Get settings
|
541 |
+
$config = new woo_dicount_rules_WooDiscountBase();
|
542 |
+
$config = $config->getBaseConfig();
|
543 |
+
if (is_string($config)) $config = json_decode($config, true);
|
544 |
+
if(isset($config['cart_setup'])){
|
545 |
+
$cart_setup = $config['cart_setup'];
|
546 |
+
} else {
|
547 |
+
$cart_setup = 'all';
|
548 |
+
}
|
549 |
+
|
550 |
+
if(count($this->rule_sets)){
|
551 |
+
if(in_array($cart_setup, array('first', 'all'))){
|
552 |
+
if($cart_setup == 'first'){
|
553 |
+
// Processing the Totals.
|
554 |
+
foreach ($this->rule_sets as $index => $rule) {
|
555 |
+
if ($rule['enabled'] == true) {
|
556 |
+
$discounts['name'][$index] = $rule['name'];
|
557 |
+
$discounts['type'][$index] = $rule['discount_type'];
|
558 |
+
if ($rule['discount_type'] == 'price_discount') {
|
559 |
+
// Getting the Flat Rate of Discount.
|
560 |
+
$discounts['to_discount'][$index] = $this->calculateDiscount($this->sub_total, array('type' => 'price', 'value' => $rule['to_discount']));
|
561 |
+
} else {
|
562 |
+
// Getting the Percentage level of Discount.
|
563 |
+
$discounts['to_discount'][$index] = $this->calculateDiscount($this->sub_total, array('type' => 'percentage', 'value' => $rule['to_discount']));
|
564 |
+
}
|
565 |
+
// Sum of Available discount list.
|
566 |
+
$discount += $discounts['to_discount'][$index];
|
567 |
+
// Update the status of the status of the discount rule.
|
568 |
+
$discounts['is_enabled'][$index] = $rule['enabled'];
|
569 |
+
break;
|
570 |
+
}
|
571 |
+
}
|
572 |
} else {
|
573 |
+
// Processing the Totals.
|
574 |
+
foreach ($this->rule_sets as $index => $rule) {
|
575 |
+
if ($rule['enabled'] == true) {
|
576 |
+
$discounts['name'][$index] = $rule['name'];
|
577 |
+
$discounts['type'][$index] = $rule['discount_type'];
|
578 |
+
if ($rule['discount_type'] == 'price_discount') {
|
579 |
+
// Getting the Flat Rate of Discount.
|
580 |
+
$discounts['to_discount'][$index] = $this->calculateDiscount($this->sub_total, array('type' => 'price', 'value' => $rule['to_discount']));
|
581 |
+
} else {
|
582 |
+
// Getting the Percentage level of Discount.
|
583 |
+
$discounts['to_discount'][$index] = $this->calculateDiscount($this->sub_total, array('type' => 'percentage', 'value' => $rule['to_discount']));
|
584 |
+
}
|
585 |
+
// Sum of Available discount list.
|
586 |
+
$discount += $discounts['to_discount'][$index];
|
587 |
+
// Update the status of the status of the discount rule.
|
588 |
+
$discounts['is_enabled'][$index] = $rule['enabled'];
|
589 |
+
}
|
590 |
+
}
|
591 |
+
}
|
592 |
+
} else if($cart_setup == 'biggest'){
|
593 |
+
$biggestDiscount = 0;
|
594 |
+
// Processing the Totals.
|
595 |
+
foreach ($this->rule_sets as $index => $rule) {
|
596 |
+
if ($rule['enabled'] == true) {
|
597 |
+
if ($rule['discount_type'] == 'price_discount') {
|
598 |
+
// Getting the Flat Rate of Discount.
|
599 |
+
$newDiscount = $this->calculateDiscount($this->sub_total, array('type' => 'price', 'value' => $rule['to_discount']));
|
600 |
+
} else {
|
601 |
+
// Getting the Percentage level of Discount.
|
602 |
+
$newDiscount = $this->calculateDiscount($this->sub_total, array('type' => 'percentage', 'value' => $rule['to_discount']));
|
603 |
+
}
|
604 |
+
|
605 |
+
if($newDiscount > $biggestDiscount){
|
606 |
+
$biggestDiscount = $newDiscount;
|
607 |
+
$discounts['name'][1] = $rule['name'];
|
608 |
+
$discounts['type'][1] = $rule['discount_type'];
|
609 |
+
$discounts['to_discount'][1] = $newDiscount;
|
610 |
+
$discount = $newDiscount;
|
611 |
+
// Update the status of the status of the discount rule.
|
612 |
+
$discounts['is_enabled'][1] = $rule['enabled'];
|
613 |
+
}
|
614 |
+
}
|
615 |
}
|
|
|
|
|
|
|
|
|
616 |
}
|
617 |
}
|
618 |
+
|
619 |
$this->discount_total = $discount;
|
620 |
return $discounts;
|
621 |
}
|
includes/pricing-rules.php
CHANGED
@@ -877,7 +877,6 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
|
|
877 |
|
878 |
// Check with Active User Filter.
|
879 |
if (isset($rule->customer)) {
|
880 |
-
// print_r($rule->customer);exit;
|
881 |
$status = false;
|
882 |
if ($rule->customer == 'all') {
|
883 |
$status = true;
|
@@ -963,7 +962,15 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
|
|
963 |
{
|
964 |
global $woocommerce;
|
965 |
|
966 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
967 |
|
968 |
$cart_items = $woocommerce->cart->cart_contents;
|
969 |
|
@@ -1051,11 +1058,13 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
|
|
1051 |
// For All, All rules going to apply.
|
1052 |
if (isset($set['amount']['percentage_discount'])) {
|
1053 |
$discount = ((int)$price / 100) * (int)$set['amount']['percentage_discount'];
|
|
|
|
|
1054 |
} else if (isset($set['amount']['price_discount'])) {
|
1055 |
$discount = $set['amount']['price_discount'];
|
|
|
|
|
1056 |
}
|
1057 |
-
// Append all Discounts.
|
1058 |
-
$overall_discount = $overall_discount + $discount;
|
1059 |
}
|
1060 |
}
|
1061 |
return $overall_discount;
|
877 |
|
878 |
// Check with Active User Filter.
|
879 |
if (isset($rule->customer)) {
|
|
|
880 |
$status = false;
|
881 |
if ($rule->customer == 'all') {
|
882 |
$status = true;
|
962 |
{
|
963 |
global $woocommerce;
|
964 |
|
965 |
+
// Get settings
|
966 |
+
$config = new woo_dicount_rules_WooDiscountBase();
|
967 |
+
$config = $config->getBaseConfig();
|
968 |
+
if (is_string($config)) $config = json_decode($config, true);
|
969 |
+
if(isset($config['price_setup'])){
|
970 |
+
$type = $config['price_setup'];
|
971 |
+
} else {
|
972 |
+
$type = 'all';
|
973 |
+
}
|
974 |
|
975 |
$cart_items = $woocommerce->cart->cart_contents;
|
976 |
|
1058 |
// For All, All rules going to apply.
|
1059 |
if (isset($set['amount']['percentage_discount'])) {
|
1060 |
$discount = ((int)$price / 100) * (int)$set['amount']['percentage_discount'];
|
1061 |
+
// Append all Discounts.
|
1062 |
+
$overall_discount = $overall_discount + $discount;
|
1063 |
} else if (isset($set['amount']['price_discount'])) {
|
1064 |
$discount = $set['amount']['price_discount'];
|
1065 |
+
// Append all Discounts.
|
1066 |
+
$overall_discount = $overall_discount + $discount;
|
1067 |
}
|
|
|
|
|
1068 |
}
|
1069 |
}
|
1070 |
return $overall_discount;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
|
|
4 |
Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
4 |
Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 1.4.5
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
woo-discount-rules.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 1.4.
|
9 |
* Requires at least: 4.6.1
|
10 |
*/
|
11 |
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 1.4.5
|
9 |
* Requires at least: 4.6.1
|
10 |
*/
|
11 |
|