Version Description
- 17/05/22 =
- Improvement: Added template override path for Bulk table.
- Improvement: Removed backslash while using single quote on promotion message.
- Improvement: Event: advanced_woo_discount_rules_allowed_html_elements_and_attributes.
- Improvement: Load rule id on discount table info for BXGY and Set discount.
- Improvement: V1 to v2 migration limit.
- Fix: Table compare issue.
- Fix: Division by zero.
- Fix: Warning on get cart.
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.4.1
- readme.txt +11 -1
- v2/App/Compatibility/CurrencySwitcherByVillatheme.php +3 -1
- v2/App/Compatibility/CurrencySwitcherByWPWham.php +3 -1
- v2/App/Controllers/Configuration.php +3 -3
- v2/App/Controllers/DiscountCalculator.php +11 -5
- v2/App/Controllers/ManageDiscount.php +21 -7
- v2/App/Helpers/Helper.php +2 -2
- v2/App/Helpers/Migration.php +3 -2
- v2/App/Helpers/Rule.php +2 -0
- v2/App/Helpers/Woocommerce.php +4 -2
- v2/App/Models/DBTable.php +7 -7
- v2/App/Views/Admin/Rules/Discounts/Bulk.php +1 -1
- v2/App/Views/Admin/Rules/Discounts/Cart.php +1 -1
- v2/App/Views/Admin/Rules/Discounts/Main.php +1 -1
- v2/App/Views/Admin/Rules/Discounts/simple.php +1 -1
- v2/App/Views/Admin/Rules/Others/QuantityPromotion.php +1 -1
- v2/App/Views/Admin/Rules/Others/SubtotalPromotion.php +1 -1
- woo-discount-rules.php +3 -3
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
|
|
4 |
Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.9
|
7 |
-
Stable tag: 2.4.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -336,6 +336,16 @@ Note : Enable recursive checkbox if the discounts should be applied in sequentia
|
|
336 |
|
337 |
== Changelog ==
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
= 2.4.0 - 06/04/22 =
|
340 |
* Deprecated: V1 layout.
|
341 |
* Fix: Calculating discount for out of stock product variant.
|
4 |
Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.9
|
7 |
+
Stable tag: 2.4.1
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
336 |
|
337 |
== Changelog ==
|
338 |
|
339 |
+
= 2.4.1 - 17/05/22 =
|
340 |
+
* Improvement: Added template override path for Bulk table.
|
341 |
+
* Improvement: Removed backslash while using single quote on promotion message.
|
342 |
+
* Improvement: Event: advanced_woo_discount_rules_allowed_html_elements_and_attributes.
|
343 |
+
* Improvement: Load rule id on discount table info for BXGY and Set discount.
|
344 |
+
* Improvement: V1 to v2 migration limit.
|
345 |
+
* Fix: Table compare issue.
|
346 |
+
* Fix: Division by zero.
|
347 |
+
* Fix: Warning on get cart.
|
348 |
+
|
349 |
= 2.4.0 - 06/04/22 =
|
350 |
* Deprecated: V1 layout.
|
351 |
* Fix: Calculating discount for out of stock product variant.
|
v2/App/Compatibility/CurrencySwitcherByVillatheme.php
CHANGED
@@ -32,7 +32,9 @@ class CurrencySwitcherByVillatheme extends Base
|
|
32 |
return $price;
|
33 |
}
|
34 |
if ( $price ) {
|
35 |
-
$
|
|
|
|
|
36 |
}
|
37 |
}
|
38 |
}
|
32 |
return $price;
|
33 |
}
|
34 |
if ( $price ) {
|
35 |
+
if($selected_currencies[ $current_currency ]['rate'] != 0){
|
36 |
+
$price = $price / $selected_currencies[ $current_currency ]['rate'];
|
37 |
+
}
|
38 |
}
|
39 |
}
|
40 |
}
|
v2/App/Compatibility/CurrencySwitcherByWPWham.php
CHANGED
@@ -20,7 +20,9 @@ class CurrencySwitcherByWPWham extends Base
|
|
20 |
if (class_exists( 'Alg_WC_Currency_Switcher' ) ) {
|
21 |
if(function_exists('alg_wc_cs_get_currency_exchange_rate') && function_exists('alg_get_current_currency_code')){
|
22 |
$alg_wc_cs = alg_wc_cs_get_currency_exchange_rate(alg_get_current_currency_code());
|
23 |
-
$
|
|
|
|
|
24 |
}
|
25 |
}
|
26 |
}
|
20 |
if (class_exists( 'Alg_WC_Currency_Switcher' ) ) {
|
21 |
if(function_exists('alg_wc_cs_get_currency_exchange_rate') && function_exists('alg_get_current_currency_code')){
|
22 |
$alg_wc_cs = alg_wc_cs_get_currency_exchange_rate(alg_get_current_currency_code());
|
23 |
+
if($alg_wc_cs != 0){
|
24 |
+
$price = $price / $alg_wc_cs;
|
25 |
+
}
|
26 |
}
|
27 |
}
|
28 |
}
|
v2/App/Controllers/Configuration.php
CHANGED
@@ -115,12 +115,12 @@ class Configuration
|
|
115 |
$this->setConfig();
|
116 |
}
|
117 |
if (isset(self::$config[$key])) {
|
118 |
-
return self::$config[$key];
|
119 |
} elseif (isset(self::$advanced_section_config[$key])){
|
120 |
-
return self::$advanced_section_config[$key];
|
121 |
}elseif (isset(self::$default_config[$key])) {
|
122 |
//Check config found in default config
|
123 |
-
return self::$default_config[$key];
|
124 |
} else {
|
125 |
return $default;
|
126 |
}
|
115 |
$this->setConfig();
|
116 |
}
|
117 |
if (isset(self::$config[$key])) {
|
118 |
+
return wp_unslash(self::$config[$key]);
|
119 |
} elseif (isset(self::$advanced_section_config[$key])){
|
120 |
+
return wp_unslash(self::$advanced_section_config[$key]);
|
121 |
}elseif (isset(self::$default_config[$key])) {
|
122 |
//Check config found in default config
|
123 |
+
return wp_unslash(self::$default_config[$key]);
|
124 |
} else {
|
125 |
return $default;
|
126 |
}
|
v2/App/Controllers/DiscountCalculator.php
CHANGED
@@ -339,7 +339,10 @@ class DiscountCalculator extends Base
|
|
339 |
case 'fixed_set_price':
|
340 |
if (!empty($value) && !empty($min) && !empty($product_price)) {
|
341 |
$value = Woocommerce::getConvertedFixedPrice($value, 'fixed_set_price');
|
342 |
-
$discounted_price =
|
|
|
|
|
|
|
343 |
if($discounted_price < 0){
|
344 |
$discounted_price = 0;
|
345 |
}
|
@@ -640,7 +643,7 @@ class DiscountCalculator extends Base
|
|
640 |
if(!empty($cart_item)) {
|
641 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
642 |
'discount_type' => 'wdr_simple_discount',
|
643 |
-
'discount_label' => $simple_discount->cart_label,
|
644 |
'discount_value' => $simple_discount->value,
|
645 |
'discounted_price' => $cart_discounted_price,
|
646 |
'rule_name' => $rule->getTitle(),
|
@@ -660,7 +663,7 @@ class DiscountCalculator extends Base
|
|
660 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
661 |
'discount_type' => 'wdr_cart_discount',
|
662 |
'apply_type' => $cart_discount->type,
|
663 |
-
'discount_label' => $discount_label,
|
664 |
'discount_value' => $cart_discount->value,
|
665 |
'discounted_price' => $discounted_price,
|
666 |
'rule_name' => $rule->getTitle(),
|
@@ -679,7 +682,7 @@ class DiscountCalculator extends Base
|
|
679 |
if(!empty($cart_item)) {
|
680 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
681 |
'discount_type' => 'wdr_bulk_discount',
|
682 |
-
'discount_label' => $bulk_discount->cart_label,
|
683 |
'discount_value' => 0,
|
684 |
'discounted_price' => $cart_discounted_price,
|
685 |
'rule_name' => $rule->getTitle(),
|
@@ -954,7 +957,10 @@ class DiscountCalculator extends Base
|
|
954 |
foreach ($discount_lines as $discount_line){
|
955 |
$discount_amount += $discount_line['discount']*$discount_line['quantity'];
|
956 |
}
|
957 |
-
$
|
|
|
|
|
|
|
958 |
|
959 |
return array('discount_price' => $discount_price, 'discount_lines' => $discount_lines);
|
960 |
}
|
339 |
case 'fixed_set_price':
|
340 |
if (!empty($value) && !empty($min) && !empty($product_price)) {
|
341 |
$value = Woocommerce::getConvertedFixedPrice($value, 'fixed_set_price');
|
342 |
+
$discounted_price = 0;
|
343 |
+
if($min > 0){
|
344 |
+
$discounted_price = $value / $min;
|
345 |
+
}
|
346 |
if($discounted_price < 0){
|
347 |
$discounted_price = 0;
|
348 |
}
|
643 |
if(!empty($cart_item)) {
|
644 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
645 |
'discount_type' => 'wdr_simple_discount',
|
646 |
+
'discount_label' => wp_unslash($simple_discount->cart_label),
|
647 |
'discount_value' => $simple_discount->value,
|
648 |
'discounted_price' => $cart_discounted_price,
|
649 |
'rule_name' => $rule->getTitle(),
|
663 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
664 |
'discount_type' => 'wdr_cart_discount',
|
665 |
'apply_type' => $cart_discount->type,
|
666 |
+
'discount_label' => wp_unslash($discount_label),
|
667 |
'discount_value' => $cart_discount->value,
|
668 |
'discounted_price' => $discounted_price,
|
669 |
'rule_name' => $rule->getTitle(),
|
682 |
if(!empty($cart_item)) {
|
683 |
$price_as_cart_discount[$rule_id][$product_id] = array(
|
684 |
'discount_type' => 'wdr_bulk_discount',
|
685 |
+
'discount_label' => wp_unslash($bulk_discount->cart_label),
|
686 |
'discount_value' => 0,
|
687 |
'discounted_price' => $cart_discounted_price,
|
688 |
'rule_name' => $rule->getTitle(),
|
957 |
foreach ($discount_lines as $discount_line){
|
958 |
$discount_amount += $discount_line['discount']*$discount_line['quantity'];
|
959 |
}
|
960 |
+
if($quantity > 0){
|
961 |
+
$discount_price = $discount_amount/$quantity;
|
962 |
+
}
|
963 |
+
|
964 |
|
965 |
return array('discount_price' => $discount_price, 'discount_lines' => $discount_lines);
|
966 |
}
|
v2/App/Controllers/ManageDiscount.php
CHANGED
@@ -166,7 +166,10 @@ class ManageDiscount extends Base
|
|
166 |
}
|
167 |
$discounted_price = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $product_price, $_product, 1, $product_price, 'discounted_price', true, false);
|
168 |
if($discounted_price !== false){
|
169 |
-
$percentage_value =
|
|
|
|
|
|
|
170 |
$percentage = apply_filters('advanced_woo_discount_rules_percentage_value_on_sale_badge', round($percentage_value, 2), $percentage_value, $_product);
|
171 |
$discount_value_to_display = Woocommerce::formatPrice(($product_price - $discounted_price));
|
172 |
$on_sale_badge_percentage_html = self::$config->getConfig('on_sale_badge_percentage_html', '<span class="onsale">{{percentage}}%</span>');
|
@@ -713,7 +716,10 @@ class ManageDiscount extends Base
|
|
713 |
return apply_filters('advanced_woo_discount_rules_strikeout_for_set_discount_price_html', $price_html, $original_price, $discounted_price, $total_discount, $other_discounts, $not_applied);
|
714 |
} else {
|
715 |
$total_product_price = array_sum($calculate_product_price);
|
716 |
-
$single_product_price = $total_product_price
|
|
|
|
|
|
|
717 |
return $single_product_price;
|
718 |
}
|
719 |
}
|
@@ -1424,7 +1430,7 @@ class ManageDiscount extends Base
|
|
1424 |
function showBulkTableInPositionManually($product, $get_variable_product_table = false)
|
1425 |
{
|
1426 |
if (!empty($product)) {
|
1427 |
-
$bulk_discounts_ranges = self::$calculator->getDefaultLayoutMessagesByRules($product, $get_variable_product_table);
|
1428 |
if(empty($bulk_discounts_ranges)){
|
1429 |
$bulk_discounts_ranges['layout']['type'] = 'default';
|
1430 |
$bulk_discounts_ranges['layout']['bulk_variant_table'] = 'default_variant_empty';
|
@@ -1458,8 +1464,12 @@ class ManageDiscount extends Base
|
|
1458 |
function showAdvancedTableInPositionManually($product)
|
1459 |
{
|
1460 |
if (!empty($product)) {
|
1461 |
-
$bulk_discounts_ranges = self::$calculator->getAdvancedLayoutMessagesByRules($product);
|
|
|
1462 |
$bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
|
|
|
|
|
|
|
1463 |
self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper))->display();
|
1464 |
}
|
1465 |
}
|
@@ -1935,7 +1945,9 @@ class ManageDiscount extends Base
|
|
1935 |
$rule_applied_product_id = isset($detail['applied_product_ids']) ? $detail['applied_product_ids'] : array();
|
1936 |
$cart_discount_price = isset( $meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'][$item_product_id][$key])? $meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'][$item_product_id][$key] : 0;
|
1937 |
$meta_discount_details['cart_discount_details'][$key]['cart_discount_price'] = $cart_discount_price;
|
1938 |
-
$
|
|
|
|
|
1939 |
$meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'] = $cart_discount_price;
|
1940 |
unset($meta_discount_details['cart_discount_details'][$key]['applied_product_ids']);
|
1941 |
if(!in_array($item_product_id,$rule_applied_product_id)){
|
@@ -2034,7 +2046,9 @@ class ManageDiscount extends Base
|
|
2034 |
$bogo_cheapest_quantity_extra = (int)$bogo_cheapest_quantity_extra - 1;
|
2035 |
$bogo_cheapest_aditional_discount += $bogo_cheapest_discount_extra*$bogo_cheapest_quantity_extra;
|
2036 |
}
|
2037 |
-
$
|
|
|
|
|
2038 |
$discounted_price = $discounted_price-$bogo_cheapest_aditional_discount;
|
2039 |
$bogo_cheap_in_cart = array();
|
2040 |
}else{
|
@@ -2527,7 +2541,7 @@ class ManageDiscount extends Base
|
|
2527 |
$messages = empty($cart) ? '' : $messages;
|
2528 |
if(!empty($messages) && is_array($messages)) {
|
2529 |
foreach ($messages as $message) {
|
2530 |
-
|
2531 |
}
|
2532 |
}
|
2533 |
}
|
166 |
}
|
167 |
$discounted_price = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $product_price, $_product, 1, $product_price, 'discounted_price', true, false);
|
168 |
if($discounted_price !== false){
|
169 |
+
$percentage_value = 0;
|
170 |
+
if($product_price != 0){
|
171 |
+
$percentage_value = (( $product_price - $discounted_price ) / $product_price) * 100;
|
172 |
+
}
|
173 |
$percentage = apply_filters('advanced_woo_discount_rules_percentage_value_on_sale_badge', round($percentage_value, 2), $percentage_value, $_product);
|
174 |
$discount_value_to_display = Woocommerce::formatPrice(($product_price - $discounted_price));
|
175 |
$on_sale_badge_percentage_html = self::$config->getConfig('on_sale_badge_percentage_html', '<span class="onsale">{{percentage}}%</span>');
|
716 |
return apply_filters('advanced_woo_discount_rules_strikeout_for_set_discount_price_html', $price_html, $original_price, $discounted_price, $total_discount, $other_discounts, $not_applied);
|
717 |
} else {
|
718 |
$total_product_price = array_sum($calculate_product_price);
|
719 |
+
$single_product_price = $total_product_price;
|
720 |
+
if($total_quantity != 0){
|
721 |
+
$single_product_price = $total_product_price / $total_quantity;
|
722 |
+
}
|
723 |
return $single_product_price;
|
724 |
}
|
725 |
}
|
1430 |
function showBulkTableInPositionManually($product, $get_variable_product_table = false)
|
1431 |
{
|
1432 |
if (!empty($product)) {
|
1433 |
+
$bulk_discounts_ranges = wp_unslash(self::$calculator->getDefaultLayoutMessagesByRules($product, $get_variable_product_table));
|
1434 |
if(empty($bulk_discounts_ranges)){
|
1435 |
$bulk_discounts_ranges['layout']['type'] = 'default';
|
1436 |
$bulk_discounts_ranges['layout']['bulk_variant_table'] = 'default_variant_empty';
|
1464 |
function showAdvancedTableInPositionManually($product)
|
1465 |
{
|
1466 |
if (!empty($product)) {
|
1467 |
+
$bulk_discounts_ranges = wp_unslash(self::$calculator->getAdvancedLayoutMessagesByRules($product));
|
1468 |
+
$override_path = get_theme_file_path('advanced_woo_discount_rules/discount_table.php');
|
1469 |
$bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
|
1470 |
+
if (file_exists($override_path)) {
|
1471 |
+
$bulk_table_template_path = $override_path;
|
1472 |
+
}
|
1473 |
self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper))->display();
|
1474 |
}
|
1475 |
}
|
1945 |
$rule_applied_product_id = isset($detail['applied_product_ids']) ? $detail['applied_product_ids'] : array();
|
1946 |
$cart_discount_price = isset( $meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'][$item_product_id][$key])? $meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'][$item_product_id][$key] : 0;
|
1947 |
$meta_discount_details['cart_discount_details'][$key]['cart_discount_price'] = $cart_discount_price;
|
1948 |
+
if($item_quantity != 0){
|
1949 |
+
$cart_discount_price = $cart_discount_price / $item_quantity;
|
1950 |
+
}
|
1951 |
$meta_discount_details['cart_discount_details'][$key]['cart_discount_product_price'] = $cart_discount_price;
|
1952 |
unset($meta_discount_details['cart_discount_details'][$key]['applied_product_ids']);
|
1953 |
if(!in_array($item_product_id,$rule_applied_product_id)){
|
2046 |
$bogo_cheapest_quantity_extra = (int)$bogo_cheapest_quantity_extra - 1;
|
2047 |
$bogo_cheapest_aditional_discount += $bogo_cheapest_discount_extra*$bogo_cheapest_quantity_extra;
|
2048 |
}
|
2049 |
+
if($cart_item_qty != 0){
|
2050 |
+
$bogo_cheapest_aditional_discount = $bogo_cheapest_aditional_discount / $cart_item_qty;
|
2051 |
+
}
|
2052 |
$discounted_price = $discounted_price-$bogo_cheapest_aditional_discount;
|
2053 |
$bogo_cheap_in_cart = array();
|
2054 |
}else{
|
2541 |
$messages = empty($cart) ? '' : $messages;
|
2542 |
if(!empty($messages) && is_array($messages)) {
|
2543 |
foreach ($messages as $message) {
|
2544 |
+
self::$woocommerce_helper->printNotice($message, "notice");
|
2545 |
}
|
2546 |
}
|
2547 |
}
|
v2/App/Helpers/Helper.php
CHANGED
@@ -332,9 +332,9 @@ class Helper
|
|
332 |
|
333 |
public static function displayCompatibleCheckMessages()
|
334 |
{
|
335 |
-
if (version_compare(WDR_VERSION, '2.4.
|
336 |
if (defined('WDR_PRO_VERSION')) {
|
337 |
-
if (version_compare(WDR_PRO_VERSION, '2.4.
|
338 |
$url = admin_url() . "plugins.php";
|
339 |
$plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', 'woo-discount-rules') . '</a>';
|
340 |
?>
|
332 |
|
333 |
public static function displayCompatibleCheckMessages()
|
334 |
{
|
335 |
+
if (version_compare(WDR_VERSION, '2.4.1', '>=')) {
|
336 |
if (defined('WDR_PRO_VERSION')) {
|
337 |
+
if (version_compare(WDR_PRO_VERSION, '2.4.1', '<')) {
|
338 |
$url = admin_url() . "plugins.php";
|
339 |
$plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', 'woo-discount-rules') . '</a>';
|
340 |
?>
|
v2/App/Helpers/Migration.php
CHANGED
@@ -9,7 +9,7 @@ class Migration
|
|
9 |
protected $form;
|
10 |
protected $rule;
|
11 |
protected $migrated_option_key = 'awdr_migration_info';
|
12 |
-
protected $migration_count_on_a_set =
|
13 |
|
14 |
public function __construct()
|
15 |
{
|
@@ -1052,7 +1052,8 @@ class Migration
|
|
1052 |
}
|
1053 |
|
1054 |
protected function getDiscountTypeFromV1($discount_range){
|
1055 |
-
if(isset($discount_range[0])){
|
|
|
1056 |
$discount_type = $discount_range[0]->discount_type;
|
1057 |
} else {
|
1058 |
$discount_type = $discount_range->{0}->discount_type;
|
9 |
protected $form;
|
10 |
protected $rule;
|
11 |
protected $migrated_option_key = 'awdr_migration_info';
|
12 |
+
protected $migration_count_on_a_set = -1;
|
13 |
|
14 |
public function __construct()
|
15 |
{
|
1052 |
}
|
1053 |
|
1054 |
protected function getDiscountTypeFromV1($discount_range){
|
1055 |
+
// if(isset($discount_range[0])){
|
1056 |
+
if(is_array($discount_range) && isset($discount_range[0])){
|
1057 |
$discount_type = $discount_range[0]->discount_type;
|
1058 |
} else {
|
1059 |
$discount_type = $discount_range->{0}->discount_type;
|
v2/App/Helpers/Rule.php
CHANGED
@@ -1480,6 +1480,8 @@ class Rule
|
|
1480 |
'h1' => array('class' => array()),
|
1481 |
'h2' => array('class' => array()),
|
1482 |
);
|
|
|
|
|
1483 |
return wp_kses($html, $allowed_html);
|
1484 |
}
|
1485 |
return $value;
|
1480 |
'h1' => array('class' => array()),
|
1481 |
'h2' => array('class' => array()),
|
1482 |
);
|
1483 |
+
// Since v2.4.1
|
1484 |
+
$allowed_html = apply_filters( 'advanced_woo_discount_rules_allowed_html_elements_and_attributes', $allowed_html);
|
1485 |
return wp_kses($html, $allowed_html);
|
1486 |
}
|
1487 |
return $value;
|
v2/App/Helpers/Woocommerce.php
CHANGED
@@ -490,7 +490,9 @@ class Woocommerce
|
|
490 |
if (function_exists('WC')) {
|
491 |
if(isset(WC()->cart) && WC()->cart != null){
|
492 |
if (method_exists(WC()->cart, 'get_cart')) {
|
493 |
-
|
|
|
|
|
494 |
}
|
495 |
}
|
496 |
}
|
@@ -868,7 +870,7 @@ class Woocommerce
|
|
868 |
static function printNotice($message, $type)
|
869 |
{
|
870 |
if (function_exists('wc_print_notice')) {
|
871 |
-
wc_print_notice($message, $type);
|
872 |
}
|
873 |
}
|
874 |
|
490 |
if (function_exists('WC')) {
|
491 |
if(isset(WC()->cart) && WC()->cart != null){
|
492 |
if (method_exists(WC()->cart, 'get_cart')) {
|
493 |
+
if (did_action('wp_loaded')) {
|
494 |
+
$cart = WC()->cart->get_cart();
|
495 |
+
}
|
496 |
}
|
497 |
}
|
498 |
}
|
870 |
static function printNotice($message, $type)
|
871 |
{
|
872 |
if (function_exists('wc_print_notice')) {
|
873 |
+
wc_print_notice(wp_unslash($message), $type);
|
874 |
}
|
875 |
}
|
876 |
|
v2/App/Models/DBTable.php
CHANGED
@@ -108,13 +108,13 @@ class DBTable
|
|
108 |
`extra` longtext DEFAULT NULL,
|
109 |
PRIMARY KEY (`id`)
|
110 |
) $charset_collate;";
|
111 |
-
if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
|
112 |
dbDelta($rules_table_query);
|
113 |
}
|
114 |
-
if($wpdb->get_var("show tables like '$order_discount_table_name'") != $order_discount_table_name){
|
115 |
dbDelta($order_discount_table_query);
|
116 |
}
|
117 |
-
if($wpdb->get_var("show tables like '$order_item_discount_table_name'") != $order_item_discount_table_name){
|
118 |
dbDelta($order_item_discount_table_query);
|
119 |
}
|
120 |
}
|
@@ -177,7 +177,7 @@ class DBTable
|
|
177 |
if(isset(self::$rules['front_end']) && $cache === true){
|
178 |
return self::$rules['front_end'];
|
179 |
}
|
180 |
-
if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
|
181 |
return false;
|
182 |
}
|
183 |
$current_time = current_time('timestamp');
|
@@ -198,7 +198,7 @@ class DBTable
|
|
198 |
if(isset(self::$rules['admin_based_on_rule_id']) && $cache === true){
|
199 |
return self::$rules['admin_based_on_rule_id'];
|
200 |
}
|
201 |
-
if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
|
202 |
return false;
|
203 |
}
|
204 |
if(is_array($rule_id)){
|
@@ -213,7 +213,7 @@ class DBTable
|
|
213 |
if(isset(self::$rules['admin_based_on_rule_name']) && $cache === true){
|
214 |
return self::$rules['admin_based_on_rule_name'];
|
215 |
}
|
216 |
-
if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
|
217 |
return false;
|
218 |
}
|
219 |
$rule_name = esc_sql($rule_name);
|
@@ -222,7 +222,7 @@ class DBTable
|
|
222 |
if(isset(self::$rules['admin_all']) && $cache === true){
|
223 |
return self::$rules['admin_all'];
|
224 |
}
|
225 |
-
if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
|
226 |
return false;
|
227 |
}
|
228 |
return self::$rules['admin_all'] = $wpdb->get_results("SELECT * FROM {$rules_table_name} WHERE deleted = 0 ORDER BY priority ASC");
|
108 |
`extra` longtext DEFAULT NULL,
|
109 |
PRIMARY KEY (`id`)
|
110 |
) $charset_collate;";
|
111 |
+
if(strtolower($wpdb->get_var("show tables like '$rules_table_name'")) != strtolower($rules_table_name)){
|
112 |
dbDelta($rules_table_query);
|
113 |
}
|
114 |
+
if(strtolower($wpdb->get_var("show tables like '$order_discount_table_name'")) != strtolower($order_discount_table_name)){
|
115 |
dbDelta($order_discount_table_query);
|
116 |
}
|
117 |
+
if(strtolower($wpdb->get_var("show tables like '$order_item_discount_table_name'")) != strtolower($order_item_discount_table_name)){
|
118 |
dbDelta($order_item_discount_table_query);
|
119 |
}
|
120 |
}
|
177 |
if(isset(self::$rules['front_end']) && $cache === true){
|
178 |
return self::$rules['front_end'];
|
179 |
}
|
180 |
+
if(strtolower($wpdb->get_var("show tables like '$rules_table_name'")) != strtolower($rules_table_name)){
|
181 |
return false;
|
182 |
}
|
183 |
$current_time = current_time('timestamp');
|
198 |
if(isset(self::$rules['admin_based_on_rule_id']) && $cache === true){
|
199 |
return self::$rules['admin_based_on_rule_id'];
|
200 |
}
|
201 |
+
if(strtolower($wpdb->get_var("show tables like '$rules_table_name'")) != strtolower($rules_table_name)){
|
202 |
return false;
|
203 |
}
|
204 |
if(is_array($rule_id)){
|
213 |
if(isset(self::$rules['admin_based_on_rule_name']) && $cache === true){
|
214 |
return self::$rules['admin_based_on_rule_name'];
|
215 |
}
|
216 |
+
if(strtolower($wpdb->get_var("show tables like '$rules_table_name'")) != strtolower($rules_table_name)){
|
217 |
return false;
|
218 |
}
|
219 |
$rule_name = esc_sql($rule_name);
|
222 |
if(isset(self::$rules['admin_all']) && $cache === true){
|
223 |
return self::$rules['admin_all'];
|
224 |
}
|
225 |
+
if(strtolower($wpdb->get_var("show tables like '$rules_table_name'")) != strtolower($rules_table_name)){
|
226 |
return false;
|
227 |
}
|
228 |
return self::$rules['admin_all'] = $wpdb->get_results("SELECT * FROM {$rules_table_name} WHERE deleted = 0 ORDER BY priority ASC");
|
v2/App/Views/Admin/Rules/Discounts/Bulk.php
CHANGED
@@ -67,7 +67,7 @@ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
|
|
67 |
class="bulk_value_selector awdr_value_selector"
|
68 |
placeholder="<?php _e('Label', 'woo-discount-rules'); ?>" min="0"
|
69 |
value="<?php if (isset($range_value->label) && !empty($range_value->label)) {
|
70 |
-
echo $range_value->label;
|
71 |
} ?>">
|
72 |
<span class="wdr_desc_text"><?php _e('Title column For Bulk Table', 'woo-discount-rules'); ?></span>
|
73 |
</div>
|
67 |
class="bulk_value_selector awdr_value_selector"
|
68 |
placeholder="<?php _e('Label', 'woo-discount-rules'); ?>" min="0"
|
69 |
value="<?php if (isset($range_value->label) && !empty($range_value->label)) {
|
70 |
+
echo wp_unslash($range_value->label);
|
71 |
} ?>">
|
72 |
<span class="wdr_desc_text"><?php _e('Title column For Bulk Table', 'woo-discount-rules'); ?></span>
|
73 |
</div>
|
v2/App/Views/Admin/Rules/Discounts/Cart.php
CHANGED
@@ -36,7 +36,7 @@ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
|
|
36 |
<input name="cart_adjustments[label]"
|
37 |
type="text"
|
38 |
class="awdr-left-align"
|
39 |
-
value="<?php echo (isset($cart_adjustment->label)) ? $cart_adjustment->label : ''; ?>"
|
40 |
placeholder="<?php _e('Discount label', 'woo-discount-rules'); ?>"
|
41 |
style="width: 100%;">
|
42 |
<span class="wdr_desc_text awdr-clear"><?php _e('Discount Label', 'woo-discount-rules'); ?></span>
|
36 |
<input name="cart_adjustments[label]"
|
37 |
type="text"
|
38 |
class="awdr-left-align"
|
39 |
+
value="<?php echo (isset($cart_adjustment->label)) ? wp_unslash($cart_adjustment->label) : ''; ?>"
|
40 |
placeholder="<?php _e('Discount label', 'woo-discount-rules'); ?>"
|
41 |
style="width: 100%;">
|
42 |
<span class="wdr_desc_text awdr-clear"><?php _e('Discount Label', 'woo-discount-rules'); ?></span>
|
v2/App/Views/Admin/Rules/Discounts/Main.php
CHANGED
@@ -98,7 +98,7 @@ If a customer buys 2 of Product A - Small, 4 of Product A - Medium, 6 of Prod
|
|
98 |
<div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
|
99 |
<input name="bulk_adjustments[cart_label]"
|
100 |
type="text"
|
101 |
-
value="<?php echo (isset($bulk_adj_as_cart_label)) ? $bulk_adj_as_cart_label : ''; ?>"
|
102 |
placeholder="<?php esc_attr('Discount Label', 'woo-discount-rules'); ?>">
|
103 |
</div>
|
104 |
</div>
|
98 |
<div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
|
99 |
<input name="bulk_adjustments[cart_label]"
|
100 |
type="text"
|
101 |
+
value="<?php echo (isset($bulk_adj_as_cart_label)) ? wp_unslash($bulk_adj_as_cart_label) : ''; ?>"
|
102 |
placeholder="<?php esc_attr('Discount Label', 'woo-discount-rules'); ?>">
|
103 |
</div>
|
104 |
</div>
|
v2/App/Views/Admin/Rules/Discounts/simple.php
CHANGED
@@ -44,7 +44,7 @@ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
|
|
44 |
<div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
|
45 |
<input name="product_adjustments[cart_label]"
|
46 |
type="text"
|
47 |
-
value="<?php echo (isset($product_adjustments->cart_label)) ? $product_adjustments->cart_label : ''; ?>"
|
48 |
placeholder="<?php esc_attr('Discount Label', 'woo-discount-rules'); ?>">
|
49 |
</div>
|
50 |
</div>
|
44 |
<div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
|
45 |
<input name="product_adjustments[cart_label]"
|
46 |
type="text"
|
47 |
+
value="<?php echo (isset($product_adjustments->cart_label)) ? wp_unslash($product_adjustments->cart_label) : ''; ?>"
|
48 |
placeholder="<?php esc_attr('Discount Label', 'woo-discount-rules'); ?>">
|
49 |
</div>
|
50 |
</div>
|
v2/App/Views/Admin/Rules/Others/QuantityPromotion.php
CHANGED
@@ -5,7 +5,7 @@ if (!defined('ABSPATH')) {
|
|
5 |
|
6 |
$operator = isset($options->operator) ? $options->operator : 'less_than';
|
7 |
$cart_quantity_promotion_from = isset($options->cart_quantity_promotion_from) ? $options->cart_quantity_promotion_from : false;
|
8 |
-
$cart_quantity_promotion_message = isset($options->cart_quantity_promotion_message) ? $options->cart_quantity_promotion_message : false;
|
9 |
echo ($render_saved_condition == true) ? '' : '<div class="wdr-cart-quantity-promo-messeage-main">';
|
10 |
if($render_saved_condition != true && isset($i)){
|
11 |
$i = '{i}';
|
5 |
|
6 |
$operator = isset($options->operator) ? $options->operator : 'less_than';
|
7 |
$cart_quantity_promotion_from = isset($options->cart_quantity_promotion_from) ? $options->cart_quantity_promotion_from : false;
|
8 |
+
$cart_quantity_promotion_message = isset($options->cart_quantity_promotion_message) ? wp_unslash($options->cart_quantity_promotion_message) : false;
|
9 |
echo ($render_saved_condition == true) ? '' : '<div class="wdr-cart-quantity-promo-messeage-main">';
|
10 |
if($render_saved_condition != true && isset($i)){
|
11 |
$i = '{i}';
|
v2/App/Views/Admin/Rules/Others/SubtotalPromotion.php
CHANGED
@@ -5,7 +5,7 @@ if (!defined('ABSPATH')) {
|
|
5 |
|
6 |
$operator = isset($options->operator) ? $options->operator : 'less_than';
|
7 |
$subtotal_promotion_from = isset($options->subtotal_promotion_from) ? $options->subtotal_promotion_from : false;
|
8 |
-
$subtotal_promotion_message = isset($options->subtotal_promotion_message) ? $options->subtotal_promotion_message : false;
|
9 |
echo ($render_saved_condition == true) ? '' : '<div class="wdr-subtotal-promo-messeage-main">';
|
10 |
if($render_saved_condition != true && isset($i)){
|
11 |
$i = '{i}';
|
5 |
|
6 |
$operator = isset($options->operator) ? $options->operator : 'less_than';
|
7 |
$subtotal_promotion_from = isset($options->subtotal_promotion_from) ? $options->subtotal_promotion_from : false;
|
8 |
+
$subtotal_promotion_message = isset($options->subtotal_promotion_message) ? wp_unslash($options->subtotal_promotion_message) : false;
|
9 |
echo ($render_saved_condition == true) ? '' : '<div class="wdr-subtotal-promo-messeage-main">';
|
10 |
if($render_saved_condition != true && isset($i)){
|
11 |
$i = '{i}';
|
woo-discount-rules.php
CHANGED
@@ -5,13 +5,13 @@
|
|
5 |
* Description: Simple to complex discount rules for your WooCommerce store. Core package.
|
6 |
* Author: Flycart
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 2.4.
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|
12 |
* Requires at least: 4.6.1
|
13 |
* WC requires at least: 3.0
|
14 |
-
* WC tested up to: 6.
|
15 |
*/
|
16 |
if (!defined('ABSPATH')) {
|
17 |
exit;
|
@@ -21,7 +21,7 @@ if (!defined('ABSPATH')) {
|
|
21 |
* Current version of our app
|
22 |
*/
|
23 |
if (!defined('WDR_VERSION')) {
|
24 |
-
define('WDR_VERSION', '2.4.
|
25 |
}
|
26 |
|
27 |
global $awdr_load_version;
|
5 |
* Description: Simple to complex discount rules for your WooCommerce store. Core package.
|
6 |
* Author: Flycart
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 2.4.1
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|
12 |
* Requires at least: 4.6.1
|
13 |
* WC requires at least: 3.0
|
14 |
+
* WC tested up to: 6.5
|
15 |
*/
|
16 |
if (!defined('ABSPATH')) {
|
17 |
exit;
|
21 |
* Current version of our app
|
22 |
*/
|
23 |
if (!defined('WDR_VERSION')) {
|
24 |
+
define('WDR_VERSION', '2.4.1');
|
25 |
}
|
26 |
|
27 |
global $awdr_load_version;
|