Version Description
- 08/09/20 =
- Fix - Table column doesn't accepts space.
- Fix - Zipcode condition doesn't works on changing in checkout.
- Improvement - Added nonce while switch version.
- Improvement - Event advanced_woo_discount_rules_change_bulk_rule_quantity while get quantity of products in bulk rule.
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.2.1
- common.php +18 -2
- readme.txt +7 -1
- v1/assets/js/app.js +2 -1
- v2/App/Helpers/Helper.php +2 -2
- v2/App/Helpers/Rule.php +3 -0
- v2/App/Helpers/Validation.php +3 -3
- v2/App/Views/Admin/Tabs/settings.php +1 -0
- v2/Assets/Css/admin_style.css +6 -0
- v2/Assets/Js/admin_script.js +51 -24
- woo-discount-rules.php +2 -2
common.php
CHANGED
@@ -12,8 +12,14 @@ add_action('wp_ajax_awdr_auto_install_pro_plugin', function (){
|
|
12 |
add_action('wp_ajax_awdr_switch_version', function (){
|
13 |
$version = isset($_REQUEST['version'])? $_REQUEST['version']: '';
|
14 |
$page = isset($_REQUEST['page'])? $_REQUEST['page']: '';
|
|
|
15 |
$return['status'] = false;
|
16 |
$return['message'] = esc_html__('Invalid request', WDR_TEXT_DOMAIN);
|
|
|
|
|
|
|
|
|
|
|
17 |
if (current_user_can( 'manage_woocommerce' )) {
|
18 |
if($version !== '' && $page !== ''){
|
19 |
$url = admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version);
|
@@ -91,7 +97,12 @@ add_action('advanced_woo_discount_rules_on_settings_head', function () {
|
|
91 |
$button_text = __("Click here to Switch back", WDR_TEXT_DOMAIN);
|
92 |
}
|
93 |
if($has_switch){
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
echo "<div class='wdr_switch_message' style='color:#a00;font-weight: bold;'></div>";
|
96 |
echo '<div class="modal" id="wdr_switch_popup">
|
97 |
<div class="modal-sandbox"></div>
|
@@ -119,9 +130,14 @@ add_action('advanced_woo_discount_rules_content_next_to_tabs', function () {
|
|
119 |
if($version == "v1"){
|
120 |
$has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption();
|
121 |
}
|
|
|
|
|
|
|
|
|
|
|
122 |
if($has_switch){
|
123 |
$button_text = __("Switch back to Discount Rules 1.x", WDR_TEXT_DOMAIN);
|
124 |
-
echo '<button class="btn btn-info awdr-switch-version-button awdr-switch-version-button-on-tab" data-version="' . $version . '" data-page="'.$page.'">' . $button_text . '</button>';
|
125 |
}
|
126 |
});
|
127 |
|
12 |
add_action('wp_ajax_awdr_switch_version', function (){
|
13 |
$version = isset($_REQUEST['version'])? $_REQUEST['version']: '';
|
14 |
$page = isset($_REQUEST['page'])? $_REQUEST['page']: '';
|
15 |
+
$wdr_nonce = isset($_REQUEST['wdr_nonce'])? $_REQUEST['wdr_nonce']: '';
|
16 |
$return['status'] = false;
|
17 |
$return['message'] = esc_html__('Invalid request', WDR_TEXT_DOMAIN);
|
18 |
+
if($version == "v1"){
|
19 |
+
\Wdr\App\Helpers\Helper::validateRequest('wdr_ajax_switch_version', $wdr_nonce);
|
20 |
+
} else {
|
21 |
+
FlycartWooDiscountRulesGeneralHelper::validateRequest('wdr_ajax_switch_version', $wdr_nonce);
|
22 |
+
}
|
23 |
if (current_user_can( 'manage_woocommerce' )) {
|
24 |
if($version !== '' && $page !== ''){
|
25 |
$url = admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version);
|
97 |
$button_text = __("Click here to Switch back", WDR_TEXT_DOMAIN);
|
98 |
}
|
99 |
if($has_switch){
|
100 |
+
if($version == "v1"){
|
101 |
+
$nounce = \Wdr\App\Helpers\Helper::create_nonce('wdr_ajax_switch_version');
|
102 |
+
} else {
|
103 |
+
$nounce = FlycartWooDiscountRulesGeneralHelper::createNonce('wdr_ajax_switch_version');
|
104 |
+
}
|
105 |
+
echo '<div style="background: #fff;padding: 20px;font-size: 13px;font-weight: bold;">' . $message . ' <button class="btn btn-info awdr-switch-version-button" data-version="' . $version . '" data-page="'.$page.'" data-nonce="'.$nounce.'">' . $button_text . '</button></div>';
|
106 |
echo "<div class='wdr_switch_message' style='color:#a00;font-weight: bold;'></div>";
|
107 |
echo '<div class="modal" id="wdr_switch_popup">
|
108 |
<div class="modal-sandbox"></div>
|
130 |
if($version == "v1"){
|
131 |
$has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption();
|
132 |
}
|
133 |
+
if($version == "v1"){
|
134 |
+
$nounce = \Wdr\App\Helpers\Helper::create_nonce('wdr_ajax_switch_version');
|
135 |
+
} else {
|
136 |
+
$nounce = FlycartWooDiscountRulesGeneralHelper::createNonce('wdr_ajax_switch_version');
|
137 |
+
}
|
138 |
if($has_switch){
|
139 |
$button_text = __("Switch back to Discount Rules 1.x", WDR_TEXT_DOMAIN);
|
140 |
+
echo '<button class="btn btn-info awdr-switch-version-button awdr-switch-version-button-on-tab" data-version="' . $version . '" data-page="'.$page.'" data-nonce="'.$nounce.'">' . $button_text . '</button>';
|
141 |
}
|
142 |
});
|
143 |
|
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.5
|
7 |
-
Stable tag: 2.2.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -336,6 +336,12 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
336 |
|
337 |
== Changelog ==
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
= 2.2.0 - 02/09/20 =
|
340 |
* Fix - Security checks improved.
|
341 |
* Fix - Taxonomy not listed in sale page.
|
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.5
|
7 |
+
Stable tag: 2.2.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.2.1 - 08/09/20 =
|
340 |
+
* Fix - Table column doesn't accepts space.
|
341 |
+
* Fix - Zipcode condition doesn't works on changing in checkout.
|
342 |
+
* Improvement - Added nonce while switch version.
|
343 |
+
* Improvement - Event advanced_woo_discount_rules_change_bulk_rule_quantity while get quantity of products in bulk rule.
|
344 |
+
|
345 |
= 2.2.0 - 02/09/20 =
|
346 |
* Fix - Security checks improved.
|
347 |
* Fix - Taxonomy not listed in sale page.
|
v1/assets/js/app.js
CHANGED
@@ -1155,10 +1155,11 @@ function wooo_discount_range_altered() {
|
|
1155 |
event.preventDefault();
|
1156 |
var version = $(this).attr('data-version');
|
1157 |
var page = $(this).attr('data-page');
|
|
|
1158 |
$.ajax({
|
1159 |
url: ajax_url,
|
1160 |
type: 'POST',
|
1161 |
-
data: {action: 'awdr_switch_version', version: version, page: page},
|
1162 |
success: function (data) {
|
1163 |
if(data.data.status == true){
|
1164 |
window.location.replace(data.data.url);
|
1155 |
event.preventDefault();
|
1156 |
var version = $(this).attr('data-version');
|
1157 |
var page = $(this).attr('data-page');
|
1158 |
+
var nonce = $(this).attr('data-nonce');
|
1159 |
$.ajax({
|
1160 |
url: ajax_url,
|
1161 |
type: 'POST',
|
1162 |
+
data: {action: 'awdr_switch_version', version: version, page: page, wdr_nonce: nonce},
|
1163 |
success: function (data) {
|
1164 |
if(data.data.status == true){
|
1165 |
window.location.replace(data.data.url);
|
v2/App/Helpers/Helper.php
CHANGED
@@ -251,9 +251,9 @@ class Helper
|
|
251 |
|
252 |
public static function displayCompatibleCheckMessages()
|
253 |
{
|
254 |
-
if (version_compare(WDR_VERSION, '2.2.
|
255 |
if (defined('WDR_PRO_VERSION')) {
|
256 |
-
if (version_compare(WDR_PRO_VERSION, '2.2.
|
257 |
$url = admin_url() . "plugins.php";
|
258 |
$plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', WDR_TEXT_DOMAIN) . '</a>';
|
259 |
?>
|
251 |
|
252 |
public static function displayCompatibleCheckMessages()
|
253 |
{
|
254 |
+
if (version_compare(WDR_VERSION, '2.2.1', '>=')) {
|
255 |
if (defined('WDR_PRO_VERSION')) {
|
256 |
+
if (version_compare(WDR_PRO_VERSION, '2.2.1', '<')) {
|
257 |
$url = admin_url() . "plugins.php";
|
258 |
$plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', WDR_TEXT_DOMAIN) . '</a>';
|
259 |
?>
|
v2/App/Helpers/Rule.php
CHANGED
@@ -768,6 +768,7 @@ class Rule
|
|
768 |
if (empty($ranges)) {
|
769 |
return 0;
|
770 |
}
|
|
|
771 |
$cart_items = self::$woocommerce_helper->getCart();
|
772 |
if($price_display_condition == "show_when_matched" && !$is_cart){
|
773 |
if(!$manual_request){
|
@@ -798,6 +799,8 @@ class Rule
|
|
798 |
}
|
799 |
break;
|
800 |
}
|
|
|
|
|
801 |
if (empty($quantity)) {
|
802 |
return 0;
|
803 |
}
|
768 |
if (empty($ranges)) {
|
769 |
return 0;
|
770 |
}
|
771 |
+
$cart_quantity = $quantity;
|
772 |
$cart_items = self::$woocommerce_helper->getCart();
|
773 |
if($price_display_condition == "show_when_matched" && !$is_cart){
|
774 |
if(!$manual_request){
|
799 |
}
|
800 |
break;
|
801 |
}
|
802 |
+
$rule_id = $this->getId();
|
803 |
+
$quantity = apply_filters('advanced_woo_discount_rules_change_bulk_rule_quantity', $quantity, $cart_items, $product, $cart_quantity, $price_display_condition, $is_cart, $manual_request, $rule_id);
|
804 |
if (empty($quantity)) {
|
805 |
return 0;
|
806 |
}
|
v2/App/Helpers/Validation.php
CHANGED
@@ -324,6 +324,9 @@ class Validation
|
|
324 |
'discount_label_for_combined_discounts',
|
325 |
'free_shipping_title',
|
326 |
'you_saved_text',
|
|
|
|
|
|
|
327 |
)
|
328 |
);
|
329 |
//validate yes, on, 1, true, 0 , '0'
|
@@ -353,9 +356,6 @@ class Validation
|
|
353 |
//validate slug may contains a-zA-Z0-9_-
|
354 |
$settings_fields_validator->rule('slug',
|
355 |
array(
|
356 |
-
'table_title_column_name',
|
357 |
-
'table_discount_column_name',
|
358 |
-
'table_range_column_name',
|
359 |
'calculate_discount_from',
|
360 |
'apply_product_discount_to',
|
361 |
'disable_coupon_when_rule_applied',
|
324 |
'discount_label_for_combined_discounts',
|
325 |
'free_shipping_title',
|
326 |
'you_saved_text',
|
327 |
+
'table_title_column_name',
|
328 |
+
'table_discount_column_name',
|
329 |
+
'table_range_column_name',
|
330 |
)
|
331 |
);
|
332 |
//validate yes, on, 1, true, 0 , '0'
|
356 |
//validate slug may contains a-zA-Z0-9_-
|
357 |
$settings_fields_validator->rule('slug',
|
358 |
array(
|
|
|
|
|
|
|
359 |
'calculate_discount_from',
|
360 |
'apply_product_discount_to',
|
361 |
'disable_coupon_when_rule_applied',
|
v2/App/Views/Admin/Tabs/settings.php
CHANGED
@@ -514,6 +514,7 @@
|
|
514 |
</div>
|
515 |
<div class="modal-body">
|
516 |
<p class="awdr-save-green wdr-alert-success" style="display: none;"><?php _e('Settings Saved', WDR_TEXT_DOMAIN) ?></p>
|
|
|
517 |
<p class="wdr-customizer-notes"><b><?php _e('Note:', WDR_TEXT_DOMAIN) ?></b><?php _e(" This table contains sample content for design purpose.", WDR_TEXT_DOMAIN); ?></p>
|
518 |
<div style="width: 100%">
|
519 |
<div class="wdr-customizer-container">
|
514 |
</div>
|
515 |
<div class="modal-body">
|
516 |
<p class="awdr-save-green wdr-alert-success" style="display: none;"><?php _e('Settings Saved', WDR_TEXT_DOMAIN) ?></p>
|
517 |
+
<p class="awdr-error-red wdr-alert-error" style="display: none;"><?php _e('Oops! Something went wrong.', WDR_TEXT_DOMAIN) ?></p>
|
518 |
<p class="wdr-customizer-notes"><b><?php _e('Note:', WDR_TEXT_DOMAIN) ?></b><?php _e(" This table contains sample content for design purpose.", WDR_TEXT_DOMAIN); ?></p>
|
519 |
<div style="width: 100%">
|
520 |
<div class="wdr-customizer-container">
|
v2/Assets/Css/admin_style.css
CHANGED
@@ -915,6 +915,12 @@ tr.awdr-listing-rule-tr td {
|
|
915 |
width: 98%;
|
916 |
z-index: 9999;
|
917 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
.banner-short-code-setting{
|
919 |
vertical-align: middle;
|
920 |
line-height: 39px;
|
915 |
width: 98%;
|
916 |
z-index: 9999;
|
917 |
}
|
918 |
+
.awdr-error-red{
|
919 |
+
border-radius: 5px;
|
920 |
+
padding: 10px;
|
921 |
+
width: 98%;
|
922 |
+
z-index: 9999;
|
923 |
+
}
|
924 |
.banner-short-code-setting{
|
925 |
vertical-align: middle;
|
926 |
line-height: 39px;
|
v2/Assets/Js/admin_script.js
CHANGED
@@ -381,10 +381,11 @@ jQuery(document).ready(function ($) {
|
|
381 |
event.preventDefault();
|
382 |
var version = $(this).attr('data-version');
|
383 |
var page = $(this).attr('data-page');
|
|
|
384 |
$.ajax({
|
385 |
url: ajaxurl,
|
386 |
type: 'POST',
|
387 |
-
data: {action: 'awdr_switch_version', version: version, page: page},
|
388 |
success: function (data) {
|
389 |
if (data.data.status == true) {
|
390 |
window.location.replace(data.data.url);
|
@@ -1673,29 +1674,55 @@ jQuery(document).ready(function ($) {
|
|
1673 |
notify(wdr_data.localization_data.error, 'error', alert_counter);
|
1674 |
},
|
1675 |
success: function (response) {
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1699 |
}
|
1700 |
}
|
1701 |
});
|
381 |
event.preventDefault();
|
382 |
var version = $(this).attr('data-version');
|
383 |
var page = $(this).attr('data-page');
|
384 |
+
var nonce = $(this).attr('data-nonce');
|
385 |
$.ajax({
|
386 |
url: ajaxurl,
|
387 |
type: 'POST',
|
388 |
+
data: {action: 'awdr_switch_version', version: version, page: page, wdr_nonce: nonce},
|
389 |
success: function (data) {
|
390 |
if (data.data.status == true) {
|
391 |
window.location.replace(data.data.url);
|
1674 |
notify(wdr_data.localization_data.error, 'error', alert_counter);
|
1675 |
},
|
1676 |
success: function (response) {
|
1677 |
+
switch (response.data.save_popup ){
|
1678 |
+
case 'alert_in_popup':
|
1679 |
+
if (response.data.save_popup == "alert_in_popup" && response.data.security_pass == "passed") {
|
1680 |
+
$('.awdr-save-green').show();
|
1681 |
+
setTimeout(
|
1682 |
+
function () {
|
1683 |
+
$('.awdr-save-green').fadeOut(500);
|
1684 |
+
window.location.replace(wdr_data.admin_url+'&tab=settings');
|
1685 |
+
}, 2000
|
1686 |
+
);
|
1687 |
+
}else if(response.data.save_popup == "alert_in_popup" && response.data.security_pass == "fails"){
|
1688 |
+
$('.awdr-error-red').show();
|
1689 |
+
setTimeout(
|
1690 |
+
function () {
|
1691 |
+
$('.awdr-error-red').fadeOut(500);
|
1692 |
+
window.location.replace(wdr_data.admin_url+'&tab=settings');
|
1693 |
+
}, 2000
|
1694 |
+
);
|
1695 |
+
|
1696 |
+
}
|
1697 |
+
break;
|
1698 |
+
case 'alert_in_normal':
|
1699 |
+
if (response.data.save_popup == "alert_in_normal" && response.data.security_pass == "passed") {
|
1700 |
+
notify(wdr_data.localization_data.save_settings, 'success', alert_counter);
|
1701 |
+
setTimeout(
|
1702 |
+
function () {
|
1703 |
+
window.location.replace(wdr_data.admin_url+'&tab=settings');
|
1704 |
+
}, 1000
|
1705 |
+
);
|
1706 |
+
|
1707 |
+
}else if(response.data.save_popup == "alert_in_normal" && response.data.security_pass == "fails"){
|
1708 |
+
notify(wdr_data.localization_data.error, 'error', alert_counter);
|
1709 |
+
setTimeout(
|
1710 |
+
function () {
|
1711 |
+
window.location.replace(wdr_data.admin_url+'&tab=settings');
|
1712 |
+
}, 1000
|
1713 |
+
);
|
1714 |
+
}
|
1715 |
+
break;
|
1716 |
+
default:
|
1717 |
+
$('.awdr-error-red').show();
|
1718 |
+
notify(wdr_data.localization_data.error, 'error', alert_counter);
|
1719 |
+
setTimeout(
|
1720 |
+
function () {
|
1721 |
+
$('.awdr-error-red').fadeOut(500);
|
1722 |
+
window.location.replace(wdr_data.admin_url+'&tab=settings');
|
1723 |
+
}, 1000
|
1724 |
+
);
|
1725 |
+
break;
|
1726 |
}
|
1727 |
}
|
1728 |
});
|
woo-discount-rules.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Simple to complex discount rules for your WooCommerce store. Core package.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 2.2.
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|
@@ -21,7 +21,7 @@ if (!defined('ABSPATH')) {
|
|
21 |
* Current version of our app
|
22 |
*/
|
23 |
if (!defined('WDR_VERSION')) {
|
24 |
-
define('WDR_VERSION', '2.2.
|
25 |
}
|
26 |
|
27 |
global $awdr_load_version;
|
5 |
* Description: Simple to complex discount rules for your WooCommerce store. Core package.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 2.2.1
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|
21 |
* Current version of our app
|
22 |
*/
|
23 |
if (!defined('WDR_VERSION')) {
|
24 |
+
define('WDR_VERSION', '2.2.1');
|
25 |
}
|
26 |
|
27 |
global $awdr_load_version;
|