Version Description
- 29/05/18 =
- Feature - Exclude sale item option(Pro)
- Feature - Cumulative option for attributes(Pro)
- Feature - Product history based on order count(Pro)
- Feature - Product history based on order count in specific product(Pro)
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.6.2 |
Comparing to | |
See all releases |
Code changes from version 1.6.1 to 1.6.2
- assets/css/style.css +50 -1
- assets/js/app.js +87 -11
- helper/woo-function.php +37 -0
- includes/cart-rules.php +47 -6
- includes/discount-base.php +16 -1
- includes/pricing-rules.php +197 -36
- loader.php +1 -0
- readme.txt +100 -41
- view/includes/sub-menu.php +5 -5
- view/settings.php +4 -1
- view/view-cart-rules.php +50 -8
- view/view-pricing-rules.php +116 -67
- woo-discount-rules.php +2 -2
assets/css/style.css
CHANGED
@@ -48,7 +48,7 @@
|
|
48 |
.rule_buttons_con{
|
49 |
margin-top: 15px;
|
50 |
}
|
51 |
-
.discount_rule_list {
|
52 |
border-bottom: 1px solid #ddd;
|
53 |
margin-bottom: 20px;
|
54 |
}
|
@@ -88,4 +88,53 @@
|
|
88 |
}
|
89 |
.discount_product_item_count_type {
|
90 |
width: 170px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
48 |
.rule_buttons_con{
|
49 |
margin-top: 15px;
|
50 |
}
|
51 |
+
.discount_rule_list, .cart_rules_list {
|
52 |
border-bottom: 1px solid #ddd;
|
53 |
margin-bottom: 20px;
|
54 |
}
|
88 |
}
|
89 |
.discount_product_item_count_type {
|
90 |
width: 170px !important;
|
91 |
+
}
|
92 |
+
.wdr_hide{
|
93 |
+
display: none;
|
94 |
+
}
|
95 |
+
.woo_discount_loader_outer{
|
96 |
+
position: relative;
|
97 |
+
}
|
98 |
+
.woo_discount_loader_outer .woo_discount_loader{
|
99 |
+
display: none;
|
100 |
+
position: absolute;
|
101 |
+
background-color: rgba(255,255,255,0.5);
|
102 |
+
top: 0;
|
103 |
+
left: 0;
|
104 |
+
width: 100%;
|
105 |
+
height: 100%;
|
106 |
+
text-align: center;
|
107 |
+
}
|
108 |
+
.woo_discount_loader .lds-ripple {
|
109 |
+
display: inline-block;
|
110 |
+
position: relative;
|
111 |
+
top: 50%;
|
112 |
+
width: 64px;
|
113 |
+
height: 64px;
|
114 |
+
}
|
115 |
+
.woo_discount_loader .lds-ripple div {
|
116 |
+
position: absolute;
|
117 |
+
border: 4px solid #257AF0;
|
118 |
+
opacity: 1;
|
119 |
+
border-radius: 50%;
|
120 |
+
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
|
121 |
+
}
|
122 |
+
.woo_discount_loader .lds-ripple div:nth-child(2) {
|
123 |
+
animation-delay: -0.5s;
|
124 |
+
}
|
125 |
+
@keyframes lds-ripple {
|
126 |
+
0% {
|
127 |
+
top: 28px;
|
128 |
+
left: 28px;
|
129 |
+
width: 0;
|
130 |
+
height: 0;
|
131 |
+
opacity: 1;
|
132 |
+
}
|
133 |
+
100% {
|
134 |
+
top: -1px;
|
135 |
+
left: -1px;
|
136 |
+
width: 58px;
|
137 |
+
height: 58px;
|
138 |
+
opacity: 0;
|
139 |
+
}
|
140 |
}
|
assets/js/app.js
CHANGED
@@ -67,6 +67,7 @@ function trigger_woocommerce_tooltip(){
|
|
67 |
var form = $('#form_price_rule').serialize();
|
68 |
var current = $(this);
|
69 |
var rule_id = $('#rule_id').val();
|
|
|
70 |
event.preventDefault();
|
71 |
if ($('#rule_name').val() == '') {
|
72 |
alert('Please Enter the Rule Name to Create / Save.');
|
@@ -76,6 +77,12 @@ function trigger_woocommerce_tooltip(){
|
|
76 |
url: ajax_url,
|
77 |
type: 'POST',
|
78 |
data: {action: 'savePriceRule', data: form},
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
success: function () {
|
80 |
// After Status Changed.
|
81 |
resizeChart = setTimeout(function () {
|
@@ -268,20 +275,25 @@ function trigger_woocommerce_tooltip(){
|
|
268 |
$('#general_block').show();
|
269 |
$('#restriction_block').hide();
|
270 |
$('#discount_block').hide();
|
|
|
271 |
});
|
272 |
$('.restriction_tab').on('click', function () {
|
273 |
if(validateFields() == true){
|
274 |
$('#general_block').hide();
|
275 |
$('#restriction_block').show();
|
276 |
$('#discount_block').hide();
|
|
|
277 |
}
|
278 |
});
|
279 |
$('.discount_tab').on('click', function () {
|
280 |
$('#general_block').hide();
|
281 |
$('#restriction_block').hide();
|
282 |
$('#discount_block').show();
|
|
|
283 |
});
|
284 |
|
|
|
|
|
285 |
// Manage the Type of Apply.
|
286 |
$('#apply_to').on('change', function () {
|
287 |
var option = $(this).val();
|
@@ -353,12 +365,28 @@ function trigger_woocommerce_tooltip(){
|
|
353 |
//--------------------------------------------------------------------------------------------------------------
|
354 |
|
355 |
$(document).on('click', '#add_cart_rule', function () {
|
356 |
-
|
357 |
var count = $('.cart_rules_list').length;
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
// Cloning the List.
|
360 |
var user_list = $('#cart_user_list_0 > option').clone();
|
361 |
-
var product_list = $('#cart_product_list_0 > option').clone();
|
362 |
var category_list = $('#cart_category_list_0 > option').clone();
|
363 |
var roles_list = $('#cart_roles_list_0 > option').clone();
|
364 |
var country_list = $('#cart_countries_list_0 > option').clone();
|
@@ -374,7 +402,11 @@ function trigger_woocommerce_tooltip(){
|
|
374 |
'<optgroup label="Customer Email"><option value="customer_email_tld">Email with TLD (Eg: edu)</option><option value="customer_email_domain">Email with Domain (Eg: gmail.com)</option></optgroup>' +
|
375 |
'<optgroup label="Customer Billing Details"><option value="customer_billing_city">Billing city</option></optgroup>' +
|
376 |
'<optgroup label="Customer Shipping Details"><option value="customer_shipping_state">Shipping state</option></optgroup>' +
|
377 |
-
'<optgroup label="Purchase History"
|
|
|
|
|
|
|
|
|
378 |
'<optgroup label="Coupon applied"><option value="coupon_applied_any_one">Atleast any one</option><option value="coupon_applied_all_selected">All selected</option></optgroup>' +
|
379 |
'</select></label></div>' +
|
380 |
'<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
|
@@ -389,7 +421,14 @@ function trigger_woocommerce_tooltip(){
|
|
389 |
'<div id="category_div_' + count + '"><select id="cart_category_list_' + count + '" class="category_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][category_to_apply][]"></select></div>' +
|
390 |
'<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
|
391 |
'<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
|
392 |
-
'<div id="purchase_history_div_' + count + '">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
'</div><div class="col-md-1"> <label> Action</label> <br> <a href=javascript:void(0) class="btn btn-danger remove_cart_rule">Remove</a> </div>' +
|
394 |
'</label></div>';
|
395 |
} else {
|
@@ -403,7 +442,10 @@ function trigger_woocommerce_tooltip(){
|
|
403 |
'<optgroup label="Customer Email"><option disabled>Email with TLD (Eg: edu)<b>' + pro_suffix + '</b></option><option disabled>Email with Domain (Eg: gmail.com)<b>' + pro_suffix + '</b></option></optgroup>' +
|
404 |
'<optgroup label="Customer Billing Details"><option disabled>Billing city <b>' + pro_suffix + '</b></option></optgroup>' +
|
405 |
'<optgroup label="Customer Shipping Details"><option disabled>Shipping state <b>' + pro_suffix + '</b></option></optgroup>' +
|
406 |
-
'<optgroup label="Purchase History"><option disabled>
|
|
|
|
|
|
|
407 |
'<optgroup label="Coupon applied"><option disabled>Atleast any one <b>' + pro_suffix + '</b></option><option disabled>All selected <b>' + pro_suffix + '</b></option></optgroup>' +
|
408 |
'</select></label></div>' +
|
409 |
'<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
|
@@ -419,6 +461,10 @@ function trigger_woocommerce_tooltip(){
|
|
419 |
|
420 |
// Append to Cart rules list.
|
421 |
$('#cart_rules_list').append(form);
|
|
|
|
|
|
|
|
|
422 |
|
423 |
$('.wc-customer-search').trigger( 'wc-enhanced-select-init' );
|
424 |
|
@@ -436,6 +482,7 @@ function trigger_woocommerce_tooltip(){
|
|
436 |
$('.roles_list').selectpicker('refresh');
|
437 |
$('.country_list').selectpicker('refresh');
|
438 |
$('.order_status_list').selectpicker('refresh');
|
|
|
439 |
|
440 |
// Default Hide List.
|
441 |
$('#user_div_' + count).css('display', 'none');
|
@@ -540,7 +587,7 @@ function trigger_woocommerce_tooltip(){
|
|
540 |
var form = $('#form_cart_rule').serialize();
|
541 |
var current = $(this);
|
542 |
var rule_id = $('#rule_id').val();
|
543 |
-
|
544 |
event.preventDefault();
|
545 |
if ($('#rule_name').val() == '') {
|
546 |
alert('Please Enter the Rule Name to Create / Save.');
|
@@ -550,6 +597,12 @@ function trigger_woocommerce_tooltip(){
|
|
550 |
url: ajax_url,
|
551 |
type: 'POST',
|
552 |
data: {action: 'saveCartRule', data: form},
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
success: function () {
|
554 |
// After Status Changed.
|
555 |
|
@@ -638,11 +691,16 @@ function trigger_woocommerce_tooltip(){
|
|
638 |
});
|
639 |
|
640 |
$('#based_on_purchase_history').on('change', function () {
|
641 |
-
var checked = $(
|
642 |
-
if(checked){
|
|
|
|
|
643 |
$('#based_on_purchase_history_fields').show();
|
|
|
|
|
|
|
644 |
} else {
|
645 |
-
$(
|
646 |
}
|
647 |
});
|
648 |
$('#based_on_purchase_history').trigger('change');
|
@@ -683,11 +741,18 @@ function trigger_woocommerce_tooltip(){
|
|
683 |
console.log(ajax_url);
|
684 |
var form = $('#discount_config').serialize();
|
685 |
var current = $(this);
|
|
|
686 |
current.val('Saving...');
|
687 |
$.ajax({
|
688 |
url: ajax_url,
|
689 |
type: 'POST',
|
690 |
data: {action: 'saveConfig', from: 'settings', data: form},
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
success: function () {
|
692 |
// After Removed.
|
693 |
resizeChart = setTimeout(function () {
|
@@ -750,8 +815,13 @@ function trigger_woocommerce_tooltip(){
|
|
750 |
processShowOnlyTags('roles_div_', id);
|
751 |
} else if (option == 'shipping_countries_in') {
|
752 |
processShowOnlyTags('countries_div_', id);
|
753 |
-
} else if (option == 'customer_based_on_purchase_history') {
|
754 |
processShowOnlyTags('purchase_history_div_', id);
|
|
|
|
|
|
|
|
|
|
|
755 |
} else {
|
756 |
processShowOnlyTags('general_', id);
|
757 |
}
|
@@ -766,4 +836,10 @@ function trigger_woocommerce_tooltip(){
|
|
766 |
}, 2000);
|
767 |
}
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
})(jQuery);
|
67 |
var form = $('#form_price_rule').serialize();
|
68 |
var current = $(this);
|
69 |
var rule_id = $('#rule_id').val();
|
70 |
+
var loader = $('.woo_discount_loader_outer > .woo_discount_loader');
|
71 |
event.preventDefault();
|
72 |
if ($('#rule_name').val() == '') {
|
73 |
alert('Please Enter the Rule Name to Create / Save.');
|
77 |
url: ajax_url,
|
78 |
type: 'POST',
|
79 |
data: {action: 'savePriceRule', data: form},
|
80 |
+
beforeSend: function() {
|
81 |
+
loader.show();
|
82 |
+
},
|
83 |
+
complete: function() {
|
84 |
+
loader.hide();
|
85 |
+
},
|
86 |
success: function () {
|
87 |
// After Status Changed.
|
88 |
resizeChart = setTimeout(function () {
|
275 |
$('#general_block').show();
|
276 |
$('#restriction_block').hide();
|
277 |
$('#discount_block').hide();
|
278 |
+
makeActiveForSelectedTab($("a.general_tab"));
|
279 |
});
|
280 |
$('.restriction_tab').on('click', function () {
|
281 |
if(validateFields() == true){
|
282 |
$('#general_block').hide();
|
283 |
$('#restriction_block').show();
|
284 |
$('#discount_block').hide();
|
285 |
+
makeActiveForSelectedTab($(".restriction_tab"));
|
286 |
}
|
287 |
});
|
288 |
$('.discount_tab').on('click', function () {
|
289 |
$('#general_block').hide();
|
290 |
$('#restriction_block').hide();
|
291 |
$('#discount_block').show();
|
292 |
+
makeActiveForSelectedTab($(".discount_tab"));
|
293 |
});
|
294 |
|
295 |
+
|
296 |
+
|
297 |
// Manage the Type of Apply.
|
298 |
$('#apply_to').on('change', function () {
|
299 |
var option = $(this).val();
|
365 |
//--------------------------------------------------------------------------------------------------------------
|
366 |
|
367 |
$(document).on('click', '#add_cart_rule', function () {
|
|
|
368 |
var count = $('.cart_rules_list').length;
|
369 |
+
var product_list = '';
|
370 |
+
var loader = $('.woo_discount_loader_outer > .woo_discount_loader');
|
371 |
+
$.ajax({
|
372 |
+
url: ajax_url,
|
373 |
+
type: 'POST',
|
374 |
+
data: {action: 'loadProductSelectBox', name: 'discount_rule['+count+'][purchase_history_products]'},
|
375 |
+
beforeSend: function() {
|
376 |
+
loader.show();
|
377 |
+
},
|
378 |
+
complete: function() {
|
379 |
+
loader.hide();
|
380 |
+
},
|
381 |
+
success: function (response) {
|
382 |
+
product_list = response;
|
383 |
+
$('#purchase_history_products_list_'+count).html(product_list);
|
384 |
+
$('.wc-product-search').trigger( 'wc-enhanced-select-init' );
|
385 |
+
}
|
386 |
+
});
|
387 |
+
|
388 |
// Cloning the List.
|
389 |
var user_list = $('#cart_user_list_0 > option').clone();
|
|
|
390 |
var category_list = $('#cart_category_list_0 > option').clone();
|
391 |
var roles_list = $('#cart_roles_list_0 > option').clone();
|
392 |
var country_list = $('#cart_countries_list_0 > option').clone();
|
402 |
'<optgroup label="Customer Email"><option value="customer_email_tld">Email with TLD (Eg: edu)</option><option value="customer_email_domain">Email with Domain (Eg: gmail.com)</option></optgroup>' +
|
403 |
'<optgroup label="Customer Billing Details"><option value="customer_billing_city">Billing city</option></optgroup>' +
|
404 |
'<optgroup label="Customer Shipping Details"><option value="customer_shipping_state">Shipping state</option></optgroup>' +
|
405 |
+
'<optgroup label="Purchase History">' +
|
406 |
+
'<option value="customer_based_on_purchase_history">Purchased amount</option>'+
|
407 |
+
'<option value="customer_based_on_purchase_history_order_count">Number of order purchased</option>'+
|
408 |
+
'<option value="customer_based_on_purchase_history_product_order_count">Number of order purchased in products</option>'+
|
409 |
+
'</optgroup>' +
|
410 |
'<optgroup label="Coupon applied"><option value="coupon_applied_any_one">Atleast any one</option><option value="coupon_applied_all_selected">All selected</option></optgroup>' +
|
411 |
'</select></label></div>' +
|
412 |
'<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
|
421 |
'<div id="category_div_' + count + '"><select id="cart_category_list_' + count + '" class="category_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][category_to_apply][]"></select></div>' +
|
422 |
'<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
|
423 |
'<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
|
424 |
+
'<div id="purchase_history_div_' + count + '">' +
|
425 |
+
'<div class="form-group wdr_hide" id="purchase_history_products_list_'+ count +'">'+
|
426 |
+
'</div>'+
|
427 |
+
'<select class="selectpicker purchased_history_type" data-live-search="true" name="discount_rule['+count+'][purchased_history_type]">' +
|
428 |
+
'<option value="atleast">Greater than or equal to</option>' +
|
429 |
+
'<option value="less_than_or_equal">Less than or equal to</option>' +
|
430 |
+
'</select>' +
|
431 |
+
' <input name="discount_rule[' + count + '][purchased_history_amount]" value="" type="text"/> In Order status <select id="order_status_list_' + count + '" class="order_status_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][purchase_history_order_status][]"></select></div>' +
|
432 |
'</div><div class="col-md-1"> <label> Action</label> <br> <a href=javascript:void(0) class="btn btn-danger remove_cart_rule">Remove</a> </div>' +
|
433 |
'</label></div>';
|
434 |
} else {
|
442 |
'<optgroup label="Customer Email"><option disabled>Email with TLD (Eg: edu)<b>' + pro_suffix + '</b></option><option disabled>Email with Domain (Eg: gmail.com)<b>' + pro_suffix + '</b></option></optgroup>' +
|
443 |
'<optgroup label="Customer Billing Details"><option disabled>Billing city <b>' + pro_suffix + '</b></option></optgroup>' +
|
444 |
'<optgroup label="Customer Shipping Details"><option disabled>Shipping state <b>' + pro_suffix + '</b></option></optgroup>' +
|
445 |
+
'<optgroup label="Purchase History"><option disabled>Purchased amount <b>' + pro_suffix + '</b></option>' +
|
446 |
+
'<option disabled>Number of order purchased <b>' + pro_suffix + '</b></option>' +
|
447 |
+
'<option disabled>Number of order purchased in products <b>' + pro_suffix + '</b></option>' +
|
448 |
+
'</optgroup>' +
|
449 |
'<optgroup label="Coupon applied"><option disabled>Atleast any one <b>' + pro_suffix + '</b></option><option disabled>All selected <b>' + pro_suffix + '</b></option></optgroup>' +
|
450 |
'</select></label></div>' +
|
451 |
'<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
|
461 |
|
462 |
// Append to Cart rules list.
|
463 |
$('#cart_rules_list').append(form);
|
464 |
+
if(product_list != ''){
|
465 |
+
$('#purchase_history_products_list_'+count).html(product_list);
|
466 |
+
$('.wc-product-search').trigger( 'wc-enhanced-select-init' );
|
467 |
+
}
|
468 |
|
469 |
$('.wc-customer-search').trigger( 'wc-enhanced-select-init' );
|
470 |
|
482 |
$('.roles_list').selectpicker('refresh');
|
483 |
$('.country_list').selectpicker('refresh');
|
484 |
$('.order_status_list').selectpicker('refresh');
|
485 |
+
$('.purchased_history_type').selectpicker('refresh');
|
486 |
|
487 |
// Default Hide List.
|
488 |
$('#user_div_' + count).css('display', 'none');
|
587 |
var form = $('#form_cart_rule').serialize();
|
588 |
var current = $(this);
|
589 |
var rule_id = $('#rule_id').val();
|
590 |
+
var loader = $('.woo_discount_loader_outer > .woo_discount_loader');
|
591 |
event.preventDefault();
|
592 |
if ($('#rule_name').val() == '') {
|
593 |
alert('Please Enter the Rule Name to Create / Save.');
|
597 |
url: ajax_url,
|
598 |
type: 'POST',
|
599 |
data: {action: 'saveCartRule', data: form},
|
600 |
+
beforeSend: function() {
|
601 |
+
loader.show();
|
602 |
+
},
|
603 |
+
complete: function() {
|
604 |
+
loader.hide();
|
605 |
+
},
|
606 |
success: function () {
|
607 |
// After Status Changed.
|
608 |
|
691 |
});
|
692 |
|
693 |
$('#based_on_purchase_history').on('change', function () {
|
694 |
+
var checked = $( this ).val();
|
695 |
+
if(checked == "0" || checked == ""){
|
696 |
+
$('#based_on_purchase_history_fields').hide();
|
697 |
+
} else {
|
698 |
$('#based_on_purchase_history_fields').show();
|
699 |
+
}
|
700 |
+
if(checked == "3"){
|
701 |
+
$("#purchase_history_products").show();
|
702 |
} else {
|
703 |
+
$("#purchase_history_products").hide();
|
704 |
}
|
705 |
});
|
706 |
$('#based_on_purchase_history').trigger('change');
|
741 |
console.log(ajax_url);
|
742 |
var form = $('#discount_config').serialize();
|
743 |
var current = $(this);
|
744 |
+
var loader = $('.woo_discount_loader_outer > .woo_discount_loader');
|
745 |
current.val('Saving...');
|
746 |
$.ajax({
|
747 |
url: ajax_url,
|
748 |
type: 'POST',
|
749 |
data: {action: 'saveConfig', from: 'settings', data: form},
|
750 |
+
beforeSend: function() {
|
751 |
+
loader.show();
|
752 |
+
},
|
753 |
+
complete: function() {
|
754 |
+
loader.hide();
|
755 |
+
},
|
756 |
success: function () {
|
757 |
// After Removed.
|
758 |
resizeChart = setTimeout(function () {
|
815 |
processShowOnlyTags('roles_div_', id);
|
816 |
} else if (option == 'shipping_countries_in') {
|
817 |
processShowOnlyTags('countries_div_', id);
|
818 |
+
} else if (option == 'customer_based_on_purchase_history' || option == 'customer_based_on_purchase_history_product_order_count' || option == 'customer_based_on_purchase_history_order_count') {
|
819 |
processShowOnlyTags('purchase_history_div_', id);
|
820 |
+
if(option == 'customer_based_on_purchase_history_product_order_count'){
|
821 |
+
$('#purchase_history_div_'+id+' #purchase_history_products_list_'+id).show();
|
822 |
+
} else {
|
823 |
+
$('#purchase_history_div_'+id+' #purchase_history_products_list_'+id).hide();
|
824 |
+
}
|
825 |
} else {
|
826 |
processShowOnlyTags('general_', id);
|
827 |
}
|
836 |
}, 2000);
|
837 |
}
|
838 |
|
839 |
+
function makeActiveForSelectedTab(selected){
|
840 |
+
var container = selected.closest('.nav-tab-wrapper');
|
841 |
+
container.find('.nav-tab').removeClass('nav-tab-active');
|
842 |
+
selected.addClass('nav-tab-active');
|
843 |
+
}
|
844 |
+
|
845 |
})(jQuery);
|
helper/woo-function.php
CHANGED
@@ -162,6 +162,17 @@ if(!class_exists('FlycartWoocommerceProduct')){
|
|
162 |
return FlycartWoocommerceVersion::wcVersion('3.0') ? $product->get_price() : $product->price;
|
163 |
}
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
/**
|
166 |
* Set WooCommerce product price
|
167 |
*
|
@@ -534,6 +545,32 @@ if(!class_exists('FlycartWoocommerceOrder')){
|
|
534 |
{
|
535 |
return FlycartWoocommerceVersion::wcVersion('3.0') ? $order->get_shipping_state() : $order->shipping_state;
|
536 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
}
|
539 |
|
162 |
return FlycartWoocommerceVersion::wcVersion('3.0') ? $product->get_price() : $product->price;
|
163 |
}
|
164 |
|
165 |
+
/**
|
166 |
+
* Get WooCommerce product sale price
|
167 |
+
*
|
168 |
+
* @access public
|
169 |
+
* @param array $product
|
170 |
+
* @return int/float
|
171 |
+
*/
|
172 |
+
public static function get_sale_price($product){
|
173 |
+
return FlycartWoocommerceVersion::wcVersion('3.0') ? $product->get_sale_price() : $product->sale_price;
|
174 |
+
}
|
175 |
+
|
176 |
/**
|
177 |
* Set WooCommerce product price
|
178 |
*
|
545 |
{
|
546 |
return FlycartWoocommerceVersion::wcVersion('3.0') ? $order->get_shipping_state() : $order->shipping_state;
|
547 |
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Get order product ids
|
551 |
+
*
|
552 |
+
* @access public
|
553 |
+
* @param object $order
|
554 |
+
* @return array
|
555 |
+
*/
|
556 |
+
public static function get_product_ids($order)
|
557 |
+
{
|
558 |
+
$items = $order->get_items();
|
559 |
+
$productIds = array();
|
560 |
+
if(!empty($items)){
|
561 |
+
foreach ($items as $item){
|
562 |
+
$product_id = FlycartWoocommerceVersion::wcVersion('3.0') ? $item->get_product_id() : $item['product_id'];
|
563 |
+
$variant_id = FlycartWoocommerceVersion::wcVersion('3.0') ? $item->get_variation_id() : $item['variation_id'];
|
564 |
+
if($variant_id){
|
565 |
+
$productIds[] = $variant_id;
|
566 |
+
} else {
|
567 |
+
$productIds[] = $product_id;
|
568 |
+
}
|
569 |
+
}
|
570 |
+
}
|
571 |
+
|
572 |
+
return $productIds;
|
573 |
+
}
|
574 |
}
|
575 |
}
|
576 |
|
includes/cart-rules.php
CHANGED
@@ -933,6 +933,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
|
|
933 |
return false;
|
934 |
break;
|
935 |
case 'customer_based_on_purchase_history':
|
|
|
|
|
936 |
if(count($rule)){
|
937 |
$ruleSuccess = $this->validateCartItemsBasedOnPurchaseHistory($index, $rule, $rules);
|
938 |
if($ruleSuccess){
|
@@ -1006,9 +1008,9 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
|
|
1006 |
$allowed = 0;
|
1007 |
$user = get_current_user_id();
|
1008 |
if($user){
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
$customerOrders = get_posts( array(
|
1013 |
'numberposts' => -1,
|
1014 |
'meta_key' => '_customer_user',
|
@@ -1016,16 +1018,38 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
|
|
1016 |
'post_type' => wc_get_order_types(),
|
1017 |
'post_status' => $purchase_history_status_list,
|
1018 |
) );
|
1019 |
-
$totalPurchasedAmount = 0;
|
1020 |
if(!empty($customerOrders)){
|
1021 |
foreach ($customerOrders as $customerOrder) {
|
1022 |
$order = FlycartWoocommerceOrder::wc_get_order($customerOrder->ID);
|
1023 |
$total = FlycartWoocommerceOrder::get_total($order);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
$totalPurchasedAmount += $total;
|
|
|
1025 |
}
|
1026 |
}
|
1027 |
-
|
1028 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1029 |
}
|
1030 |
}
|
1031 |
}
|
@@ -1034,6 +1058,23 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
|
|
1034 |
return $allowed;
|
1035 |
}
|
1036 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1037 |
/**
|
1038 |
* verify the cart items are from selected category
|
1039 |
* */
|
933 |
return false;
|
934 |
break;
|
935 |
case 'customer_based_on_purchase_history':
|
936 |
+
case 'customer_based_on_purchase_history_order_count':
|
937 |
+
case 'customer_based_on_purchase_history_product_order_count':
|
938 |
if(count($rule)){
|
939 |
$ruleSuccess = $this->validateCartItemsBasedOnPurchaseHistory($index, $rule, $rules);
|
940 |
if($ruleSuccess){
|
1008 |
$allowed = 0;
|
1009 |
$user = get_current_user_id();
|
1010 |
if($user){
|
1011 |
+
$purchase_history_status_list = isset($rule['purchase_history_order_status'])? $rule['purchase_history_order_status']: array('wc-completed');
|
1012 |
+
if(isset($rule['purchased_history_amount'])){
|
1013 |
+
if($rule['purchased_history_amount'] >= 0){
|
1014 |
$customerOrders = get_posts( array(
|
1015 |
'numberposts' => -1,
|
1016 |
'meta_key' => '_customer_user',
|
1018 |
'post_type' => wc_get_order_types(),
|
1019 |
'post_status' => $purchase_history_status_list,
|
1020 |
) );
|
1021 |
+
$totalPurchasedAmount = $totalOrder = 0;
|
1022 |
if(!empty($customerOrders)){
|
1023 |
foreach ($customerOrders as $customerOrder) {
|
1024 |
$order = FlycartWoocommerceOrder::wc_get_order($customerOrder->ID);
|
1025 |
$total = FlycartWoocommerceOrder::get_total($order);
|
1026 |
+
if($index == 'customer_based_on_purchase_history_product_order_count' && isset($rule['purchase_history_products'])){
|
1027 |
+
$products = $this->getProductsFromRule($rule['purchase_history_products']);
|
1028 |
+
$product_ids = FlycartWoocommerceOrder::get_product_ids($order);
|
1029 |
+
if(!empty($products)){
|
1030 |
+
if (!count(array_intersect($products, $product_ids)) > 0) {
|
1031 |
+
continue;
|
1032 |
+
}
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
$totalPurchasedAmount += $total;
|
1036 |
+
$totalOrder++;
|
1037 |
}
|
1038 |
}
|
1039 |
+
|
1040 |
+
$totalAmount = $totalPurchasedAmount;
|
1041 |
+
if($index == 'customer_based_on_purchase_history_order_count' || $index == 'customer_based_on_purchase_history_product_order_count'){
|
1042 |
+
$totalAmount = $totalOrder;
|
1043 |
+
}
|
1044 |
+
$purchased_history_type = isset($rule['purchased_history_type'])? $rule['purchased_history_type']: 'atleast';
|
1045 |
+
if($purchased_history_type == 'less_than_or_equal'){
|
1046 |
+
if($totalAmount <= $rule['purchased_history_amount']){
|
1047 |
+
$allowed = 1;
|
1048 |
+
}
|
1049 |
+
} else {
|
1050 |
+
if($totalAmount >= $rule['purchased_history_amount']){
|
1051 |
+
$allowed = 1;
|
1052 |
+
}
|
1053 |
}
|
1054 |
}
|
1055 |
}
|
1058 |
return $allowed;
|
1059 |
}
|
1060 |
|
1061 |
+
/**
|
1062 |
+
* get product from rule
|
1063 |
+
* */
|
1064 |
+
public function getProductsFromRule($product){
|
1065 |
+
$productInArray = array();
|
1066 |
+
if(empty($product)) return $productInArray;
|
1067 |
+
if(is_array($product)) $productInArray = $product;
|
1068 |
+
else if(is_string($product)){
|
1069 |
+
$productInArray = json_decode($product);
|
1070 |
+
$productInArray = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($productInArray);
|
1071 |
+
}
|
1072 |
+
if(!is_array($productInArray)){
|
1073 |
+
$productInArray = array();
|
1074 |
+
}
|
1075 |
+
return $productInArray;
|
1076 |
+
}
|
1077 |
+
|
1078 |
/**
|
1079 |
* verify the cart items are from selected category
|
1080 |
* */
|
includes/discount-base.php
CHANGED
@@ -232,6 +232,19 @@ if (!class_exists('FlycartWooDiscountBase')) {
|
|
232 |
die();
|
233 |
}
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
/**
|
236 |
* Making the reliable end data to store.
|
237 |
*
|
@@ -295,7 +308,9 @@ if (!class_exists('FlycartWooDiscountBase')) {
|
|
295 |
'users_in' => 'users_to_apply',
|
296 |
'roles_in' => 'user_roles_to_apply',
|
297 |
'shipping_countries_in' => 'countries_to_apply',
|
298 |
-
'customer_based_on_purchase_history' => array('purchase_history_order_status', 'purchased_history_amount')
|
|
|
|
|
299 |
);
|
300 |
}
|
301 |
|
232 |
die();
|
233 |
}
|
234 |
|
235 |
+
/**
|
236 |
+
* load product select box
|
237 |
+
*
|
238 |
+
* @return bool
|
239 |
+
*/
|
240 |
+
public function loadProductSelectBox() {
|
241 |
+
$postData = \FlycartInput\FInput::getInstance();
|
242 |
+
$request = $postData->getArray();
|
243 |
+
if (!isset($request['name'])) return false;
|
244 |
+
echo FlycartWoocommerceProduct::getProductAjaxSelectBox(array(), $request['name']);
|
245 |
+
die();
|
246 |
+
}
|
247 |
+
|
248 |
/**
|
249 |
* Making the reliable end data to store.
|
250 |
*
|
308 |
'users_in' => 'users_to_apply',
|
309 |
'roles_in' => 'user_roles_to_apply',
|
310 |
'shipping_countries_in' => 'countries_to_apply',
|
311 |
+
'customer_based_on_purchase_history' => array('purchase_history_order_status', 'purchased_history_amount', 'purchased_history_type'),
|
312 |
+
'customer_based_on_purchase_history_order_count' => array('purchase_history_order_status', 'purchased_history_amount', 'purchased_history_type'),
|
313 |
+
'customer_based_on_purchase_history_product_order_count' => array('purchase_history_order_status', 'purchased_history_amount', 'purchased_history_type', 'purchase_history_products'),
|
314 |
);
|
315 |
}
|
316 |
|
includes/pricing-rules.php
CHANGED
@@ -61,6 +61,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
61 |
public static $rules_loaded = 0;
|
62 |
public static $pricingRules;
|
63 |
public static $product_categories = array();
|
|
|
64 |
|
65 |
/**
|
66 |
* FlycartWooDiscountRulesPricingRules constructor.
|
@@ -150,7 +151,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
150 |
'coupons_to_apply_option',
|
151 |
'coupons_to_apply',
|
152 |
'subtotal_to_apply_option',
|
153 |
-
'subtotal_to_apply'
|
|
|
154 |
);
|
155 |
|
156 |
//----------------------------------------------------------------------------------------------------------
|
@@ -181,7 +183,14 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
181 |
$apply_to = 'product_to_apply';
|
182 |
} elseif ($apply_to == 'specific_attribute') {
|
183 |
$apply_to = 'attribute_to_apply';
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
|
|
185 |
|
186 |
if(isset($request['is_cumulative_for_products']) && $request['is_cumulative_for_products'] == 1){
|
187 |
$request['is_cumulative_for_products'] = 1;
|
@@ -190,7 +199,12 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
190 |
}
|
191 |
$form[] = 'is_cumulative_for_products';
|
192 |
|
193 |
-
$
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
if (isset($request[$apply_to])) $request[$apply_to] = json_encode($request[$apply_to]);
|
196 |
//----------------------------------------------------------------------------------------------------------
|
@@ -218,6 +232,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
218 |
$form[] = 'purchased_history_amount';
|
219 |
$form[] = 'purchased_history_type';
|
220 |
$form[] = 'purchase_history_status_list';
|
|
|
221 |
if (isset($request['purchase_history_status_list'])) $request['purchase_history_status_list'] = json_encode($request['purchase_history_status_list']);
|
222 |
else $request['purchase_history_status_list'] = json_encode(array('wc-completed'));
|
223 |
}
|
@@ -530,8 +545,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
530 |
}
|
531 |
} else {
|
532 |
$carts = FlycartWoocommerceCart::get_cart();
|
533 |
-
foreach ($carts as $cart_item) {
|
534 |
-
if($cart_item_key == $
|
535 |
$cart_data = $cart_item;
|
536 |
break;
|
537 |
}
|
@@ -582,7 +597,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
582 |
} else {
|
583 |
FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
|
584 |
}
|
585 |
-
|
|
|
|
|
|
|
|
|
586 |
}
|
587 |
}
|
588 |
}
|
@@ -647,6 +666,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
647 |
$rule_sets[$index]['allow']['users'] = 'all';
|
648 |
$rule_sets[$index]['allow']['user_role'] = $rule_sets[$index]['allow']['subtotal'] = true;
|
649 |
$rule_sets[$index]['allow']['coupon'] = 1;
|
|
|
650 |
|
651 |
// For quantity based discount
|
652 |
if($rule_sets[$index]['method'] == 'qty_based'){
|
@@ -677,12 +697,20 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
677 |
$rule_sets[$index]['type']['is_cumulative'] = 0;
|
678 |
}
|
679 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
|
|
680 |
} else if ($rule->apply_to == 'specific_attribute') {
|
681 |
$rule_sets[$index]['type']['specific_attribute'] = $this->getAttributeFromRule($rule, $woocommerce);
|
682 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
} else {
|
684 |
$rule_sets[$index]['type'] = 'all';
|
685 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
|
|
686 |
if (isset($rule->is_cumulative_for_products) && $rule->is_cumulative_for_products) {
|
687 |
$rule_sets[$index]['is_cumulative_for_products'] = 1;
|
688 |
} else {
|
@@ -848,21 +876,35 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
848 |
'post_type' => wc_get_order_types(),
|
849 |
'post_status' => $purchase_history_status_list,
|
850 |
) );
|
851 |
-
$totalPurchasedAmount = 0;
|
852 |
if(!empty($customerOrders)){
|
853 |
foreach ($customerOrders as $customerOrder) {
|
854 |
$order = FlycartWoocommerceOrder::wc_get_order($customerOrder->ID);
|
855 |
$total = FlycartWoocommerceOrder::get_total($order);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
856 |
$totalPurchasedAmount += $total;
|
|
|
857 |
}
|
858 |
}
|
|
|
|
|
|
|
|
|
859 |
$purchased_history_type = isset($rule->purchased_history_type)? $rule->purchased_history_type: 'atleast';
|
860 |
if($purchased_history_type == 'less_than_or_equal'){
|
861 |
-
if($
|
862 |
$allowed = 'yes';
|
863 |
}
|
864 |
} else {
|
865 |
-
if($
|
866 |
$allowed = 'yes';
|
867 |
}
|
868 |
}
|
@@ -996,10 +1038,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
996 |
|
997 |
case 'specific_category':
|
998 |
$notInProductList = !$this->isItemInProductList($rule['product_to_exclude'], $item);
|
999 |
-
|
|
|
1000 |
$alreadyExists = 0;
|
1001 |
if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
|
1002 |
-
$totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category'], $rule['product_to_exclude']);
|
1003 |
$quantity = $totalQuantityInThisCategory;
|
1004 |
//Check for product_discount to apply the rule only once
|
1005 |
if(isset($rule['discount'])){
|
@@ -1028,8 +1071,31 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1028 |
break;
|
1029 |
case 'specific_attribute':
|
1030 |
$notInProductList = !$this->isItemInProductList($rule['product_to_exclude'], $item);
|
1031 |
-
|
|
|
1032 |
$alreadyExists = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1033 |
if(!$alreadyExists){
|
1034 |
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
1035 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
@@ -1039,16 +1105,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1039 |
|
1040 |
case 'all_products':
|
1041 |
default:
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
1048 |
-
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
1049 |
}
|
|
|
|
|
|
|
1050 |
|
1051 |
-
|
1052 |
}
|
1053 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
1054 |
if(!empty($applied_rules[$i]['amount']['product_ids'])){
|
@@ -1177,17 +1244,18 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1177 |
/**
|
1178 |
* Get quantity of products in specific category
|
1179 |
* */
|
1180 |
-
public function getProductQuantityInThisCategory($category, $product_to_exclude){
|
1181 |
global $woocommerce;
|
1182 |
$hasExcludeProduct = $quantity = 0;
|
1183 |
if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
|
1184 |
if(count($woocommerce->cart->cart_contents)){
|
1185 |
foreach ($woocommerce->cart->cart_contents as $cartItem) {
|
|
|
|
|
|
|
|
|
1186 |
if($hasExcludeProduct){
|
1187 |
-
$product_id = $cartItem['
|
1188 |
-
if(isset($cartItem['variation_id']) && $cartItem['variation_id']){
|
1189 |
-
$product_id = $cartItem['variation_id'];
|
1190 |
-
}
|
1191 |
if(in_array($product_id, $product_to_exclude)){
|
1192 |
continue;
|
1193 |
}
|
@@ -1217,17 +1285,60 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1217 |
return $quantity;
|
1218 |
}
|
1219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1220 |
/**
|
1221 |
* Get quantity of products from all products
|
1222 |
* */
|
1223 |
public function getProductQuantityForCumulativeProducts($item, $product_page, $rules){
|
1224 |
$product_to_exclude = $rules['product_to_exclude'];
|
|
|
1225 |
global $woocommerce;
|
1226 |
$hasExcludeProduct = $quantity = 0;
|
1227 |
if($product_page) $quantity++;
|
1228 |
if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
|
1229 |
if(count($woocommerce->cart->cart_contents)){
|
1230 |
foreach ($woocommerce->cart->cart_contents as $cartItem) {
|
|
|
|
|
|
|
|
|
1231 |
if($hasExcludeProduct){
|
1232 |
$product_id = $cartItem['product_id'];
|
1233 |
if(isset($cartItem['variation_id']) && $cartItem['variation_id']){
|
@@ -1539,6 +1650,22 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1539 |
}
|
1540 |
}
|
1541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1542 |
/**
|
1543 |
* To Check that the items are in specified category.
|
1544 |
*
|
@@ -1901,6 +2028,23 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1901 |
return $discount_range;
|
1902 |
}
|
1903 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1904 |
/**
|
1905 |
* To get product to exclude
|
1906 |
* */
|
@@ -2343,13 +2487,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2343 |
);
|
2344 |
|
2345 |
// To handle Woocommerce currency switcher
|
2346 |
-
global $WOOCS;
|
2347 |
-
if(isset($WOOCS)){
|
2348 |
-
if (method_exists($WOOCS, 'get_currencies')){
|
2349 |
-
$currencies = $WOOCS->get_currencies();
|
2350 |
-
$amount = $amount / $currencies[$WOOCS->current_currency]['rate'];
|
2351 |
-
}
|
2352 |
-
}
|
2353 |
|
2354 |
// Actually adjust price in cart
|
2355 |
// $woocommerce->cart->cart_contents[$item]['data']->price = $amount;
|
@@ -2360,6 +2504,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2360 |
$run_multiple_strikeout = true;
|
2361 |
$quantity = $cart_item['quantity'];
|
2362 |
foreach ($additional_details as $detail){
|
|
|
2363 |
if($detail['discount_quantity'] >= $quantity){
|
2364 |
$run_multiple_strikeout = false;
|
2365 |
}
|
@@ -2485,17 +2630,20 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2485 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
2486 |
if($discountPrice > 0){
|
2487 |
$price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
|
|
|
2488 |
if(FlycartWoocommerceVersion::wcVersion('3.0'))
|
2489 |
-
$price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display);
|
2490 |
-
|
2491 |
-
|
|
|
|
|
2492 |
}
|
2493 |
}
|
2494 |
|
2495 |
return $item_price;
|
2496 |
}
|
2497 |
|
2498 |
-
public function checkForHighestVariantIfExists($product, $price_to_display){
|
2499 |
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
2500 |
$child_prices = array();
|
2501 |
$children = array_filter( array_map( 'wc_get_product', FlycartWoocommerceProduct::get_children($product) ), 'wc_products_array_filter_visible_grouped' );
|
@@ -2540,8 +2688,21 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2540 |
} else {
|
2541 |
$price_to_display .= ' - '.$greatestDiscountPrice;
|
2542 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2543 |
}
|
2544 |
-
|
2545 |
return $price_to_display;
|
2546 |
}
|
2547 |
|
61 |
public static $rules_loaded = 0;
|
62 |
public static $pricingRules;
|
63 |
public static $product_categories = array();
|
64 |
+
public static $product_attributes = array();
|
65 |
|
66 |
/**
|
67 |
* FlycartWooDiscountRulesPricingRules constructor.
|
151 |
'coupons_to_apply_option',
|
152 |
'coupons_to_apply',
|
153 |
'subtotal_to_apply_option',
|
154 |
+
'subtotal_to_apply',
|
155 |
+
'exclude_sale_items'
|
156 |
);
|
157 |
|
158 |
//----------------------------------------------------------------------------------------------------------
|
183 |
$apply_to = 'product_to_apply';
|
184 |
} elseif ($apply_to == 'specific_attribute') {
|
185 |
$apply_to = 'attribute_to_apply';
|
186 |
+
if(isset($request['is_cumulative_attribute']) && $request['is_cumulative_attribute'] == 1){
|
187 |
+
$request['is_cumulative_attribute'] = 1;
|
188 |
+
} else {
|
189 |
+
$request['is_cumulative_attribute'] = 0;
|
190 |
+
}
|
191 |
+
$form[] = 'is_cumulative_attribute';
|
192 |
}
|
193 |
+
$form[] = $apply_to;
|
194 |
|
195 |
if(isset($request['is_cumulative_for_products']) && $request['is_cumulative_for_products'] == 1){
|
196 |
$request['is_cumulative_for_products'] = 1;
|
199 |
}
|
200 |
$form[] = 'is_cumulative_for_products';
|
201 |
|
202 |
+
if(isset($request['exclude_sale_items']) && $request['exclude_sale_items'] == 1){
|
203 |
+
$request['exclude_sale_items'] = 1;
|
204 |
+
} else {
|
205 |
+
$request['exclude_sale_items'] = 0;
|
206 |
+
}
|
207 |
+
|
208 |
|
209 |
if (isset($request[$apply_to])) $request[$apply_to] = json_encode($request[$apply_to]);
|
210 |
//----------------------------------------------------------------------------------------------------------
|
232 |
$form[] = 'purchased_history_amount';
|
233 |
$form[] = 'purchased_history_type';
|
234 |
$form[] = 'purchase_history_status_list';
|
235 |
+
$form[] = 'purchase_history_products';
|
236 |
if (isset($request['purchase_history_status_list'])) $request['purchase_history_status_list'] = json_encode($request['purchase_history_status_list']);
|
237 |
else $request['purchase_history_status_list'] = json_encode(array('wc-completed'));
|
238 |
}
|
545 |
}
|
546 |
} else {
|
547 |
$carts = FlycartWoocommerceCart::get_cart();
|
548 |
+
foreach ($carts as $key => $cart_item) {
|
549 |
+
if($cart_item_key == $key){
|
550 |
$cart_data = $cart_item;
|
551 |
break;
|
552 |
}
|
597 |
} else {
|
598 |
FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
|
599 |
}
|
600 |
+
$woocommerce_v3 = FlycartWoocommerceVersion::wcVersion('3.0');
|
601 |
+
if($woocommerce_v3)
|
602 |
+
add_action('woocommerce_after_cart_item_quantity_update', array($this, 'handleBOGODiscountOnUpdateQuantity'), 10, 4);
|
603 |
+
else
|
604 |
+
add_action('woocommerce_after_cart_item_quantity_update', array($this, 'handleBOGODiscountOnUpdateQuantity'), 10, 3);
|
605 |
}
|
606 |
}
|
607 |
}
|
666 |
$rule_sets[$index]['allow']['users'] = 'all';
|
667 |
$rule_sets[$index]['allow']['user_role'] = $rule_sets[$index]['allow']['subtotal'] = true;
|
668 |
$rule_sets[$index]['allow']['coupon'] = 1;
|
669 |
+
$rule_sets[$index]['exclude_sale_items'] = 0;
|
670 |
|
671 |
// For quantity based discount
|
672 |
if($rule_sets[$index]['method'] == 'qty_based'){
|
697 |
$rule_sets[$index]['type']['is_cumulative'] = 0;
|
698 |
}
|
699 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
700 |
+
if (isset($rule->exclude_sale_items) && $rule->exclude_sale_items) $rule_sets[$index]['exclude_sale_items'] = 1;
|
701 |
} else if ($rule->apply_to == 'specific_attribute') {
|
702 |
$rule_sets[$index]['type']['specific_attribute'] = $this->getAttributeFromRule($rule, $woocommerce);
|
703 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
704 |
+
if (isset($rule->exclude_sale_items) && $rule->exclude_sale_items) $rule_sets[$index]['exclude_sale_items'] = 1;
|
705 |
+
if (isset($rule->is_cumulative_attribute) && $rule->is_cumulative_attribute) {
|
706 |
+
$rule_sets[$index]['type']['is_cumulative'] = 1;
|
707 |
+
} else {
|
708 |
+
$rule_sets[$index]['type']['is_cumulative'] = 0;
|
709 |
+
}
|
710 |
} else {
|
711 |
$rule_sets[$index]['type'] = 'all';
|
712 |
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
713 |
+
if (isset($rule->exclude_sale_items) && $rule->exclude_sale_items) $rule_sets[$index]['exclude_sale_items'] = 1;
|
714 |
if (isset($rule->is_cumulative_for_products) && $rule->is_cumulative_for_products) {
|
715 |
$rule_sets[$index]['is_cumulative_for_products'] = 1;
|
716 |
} else {
|
876 |
'post_type' => wc_get_order_types(),
|
877 |
'post_status' => $purchase_history_status_list,
|
878 |
) );
|
879 |
+
$totalPurchasedAmount = $totalOrder = 0;
|
880 |
if(!empty($customerOrders)){
|
881 |
foreach ($customerOrders as $customerOrder) {
|
882 |
$order = FlycartWoocommerceOrder::wc_get_order($customerOrder->ID);
|
883 |
$total = FlycartWoocommerceOrder::get_total($order);
|
884 |
+
if($rule->based_on_purchase_history == 3){
|
885 |
+
$products = $this->getPurchasedProductsFromRule($rule);
|
886 |
+
$product_ids = FlycartWoocommerceOrder::get_product_ids($order);
|
887 |
+
if(!empty($products)){
|
888 |
+
if (!count(array_intersect($products, $product_ids)) > 0) {
|
889 |
+
continue;
|
890 |
+
}
|
891 |
+
}
|
892 |
+
}
|
893 |
$totalPurchasedAmount += $total;
|
894 |
+
$totalOrder++;
|
895 |
}
|
896 |
}
|
897 |
+
$totalAmount = $totalPurchasedAmount;
|
898 |
+
if($rule->based_on_purchase_history == 2 || $rule->based_on_purchase_history == 3){
|
899 |
+
$totalAmount = $totalOrder;
|
900 |
+
}
|
901 |
$purchased_history_type = isset($rule->purchased_history_type)? $rule->purchased_history_type: 'atleast';
|
902 |
if($purchased_history_type == 'less_than_or_equal'){
|
903 |
+
if($totalAmount <= $rule->purchased_history_amount){
|
904 |
$allowed = 'yes';
|
905 |
}
|
906 |
} else {
|
907 |
+
if($totalAmount >= $rule->purchased_history_amount){
|
908 |
$allowed = 'yes';
|
909 |
}
|
910 |
}
|
1038 |
|
1039 |
case 'specific_category':
|
1040 |
$notInProductList = !$this->isItemInProductList($rule['product_to_exclude'], $item);
|
1041 |
+
$is_not_in_exclude_sale_items = !$this->isItemInSaleItems($rule['exclude_sale_items'], $item['data']);
|
1042 |
+
if ($this->isItemInCategoryList($rule['type']['specific_category'], $item) && $notInProductList && $is_not_in_exclude_sale_items) {
|
1043 |
$alreadyExists = 0;
|
1044 |
if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
|
1045 |
+
$totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category'], $rule['product_to_exclude'], $rule['exclude_sale_items']);
|
1046 |
$quantity = $totalQuantityInThisCategory;
|
1047 |
//Check for product_discount to apply the rule only once
|
1048 |
if(isset($rule['discount'])){
|
1071 |
break;
|
1072 |
case 'specific_attribute':
|
1073 |
$notInProductList = !$this->isItemInProductList($rule['product_to_exclude'], $item);
|
1074 |
+
$is_not_in_exclude_sale_items = !$this->isItemInSaleItems($rule['exclude_sale_items'], $item['data']);
|
1075 |
+
if ($this->isItemInAttributeList($rule['type']['specific_attribute'], $item) && $notInProductList && $is_not_in_exclude_sale_items) {
|
1076 |
$alreadyExists = 0;
|
1077 |
+
if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
|
1078 |
+
$totalQuantityInThisAttribute = $this->getProductQuantityInThisAttribute($rule['type']['specific_attribute'], $rule['product_to_exclude'], $rule['exclude_sale_items'], $id);
|
1079 |
+
$quantity = $totalQuantityInThisAttribute;
|
1080 |
+
//Check for product_discount to apply the rule only once
|
1081 |
+
if(isset($rule['discount'])){
|
1082 |
+
if(!empty($rule['discount'])){
|
1083 |
+
foreach($rule['discount'] as $discount_rules){
|
1084 |
+
if(isset($discount_rules->discount_type) && $discount_rules->discount_type == 'product_discount'){
|
1085 |
+
if(!empty($this->matched_sets)){
|
1086 |
+
foreach($this->matched_sets as $machedRules){
|
1087 |
+
foreach($machedRules as $machedRule){
|
1088 |
+
if(isset($machedRule['rule_order']) && $machedRule['rule_order'] == $id){
|
1089 |
+
$alreadyExists = 1;
|
1090 |
+
}
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
}
|
1096 |
+
}
|
1097 |
+
}
|
1098 |
+
}
|
1099 |
if(!$alreadyExists){
|
1100 |
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
1101 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
1105 |
|
1106 |
case 'all_products':
|
1107 |
default:
|
1108 |
+
$is_not_in_exclude_sale_items = !$this->isItemInSaleItems($rule['exclude_sale_items'], $item['data']);
|
1109 |
+
if (!$this->isItemInProductList($rule['product_to_exclude'], $item) && $is_not_in_exclude_sale_items) {
|
1110 |
+
if(isset($rule['is_cumulative_for_products']) && $rule['is_cumulative_for_products']){
|
1111 |
+
$totalQuantityFromAllProducts = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
|
1112 |
+
$quantity = $totalQuantityFromAllProducts;
|
|
|
|
|
1113 |
}
|
1114 |
+
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
1115 |
+
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
1116 |
+
}
|
1117 |
|
1118 |
+
break;
|
1119 |
}
|
1120 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
1121 |
if(!empty($applied_rules[$i]['amount']['product_ids'])){
|
1244 |
/**
|
1245 |
* Get quantity of products in specific category
|
1246 |
* */
|
1247 |
+
public function getProductQuantityInThisCategory($category, $product_to_exclude, $exclude_sale_items){
|
1248 |
global $woocommerce;
|
1249 |
$hasExcludeProduct = $quantity = 0;
|
1250 |
if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
|
1251 |
if(count($woocommerce->cart->cart_contents)){
|
1252 |
foreach ($woocommerce->cart->cart_contents as $cartItem) {
|
1253 |
+
$is_exclude_sale_items = $this->isItemInSaleItems($exclude_sale_items, $cartItem['data']);
|
1254 |
+
if($is_exclude_sale_items){
|
1255 |
+
continue;
|
1256 |
+
}
|
1257 |
if($hasExcludeProduct){
|
1258 |
+
$product_id = FlycartWoocommerceProduct::get_id($cartItem['data']);
|
|
|
|
|
|
|
1259 |
if(in_array($product_id, $product_to_exclude)){
|
1260 |
continue;
|
1261 |
}
|
1285 |
return $quantity;
|
1286 |
}
|
1287 |
|
1288 |
+
/**
|
1289 |
+
* Get quantity of products in specific attribute
|
1290 |
+
* */
|
1291 |
+
public function getProductQuantityInThisAttribute($attribute, $product_to_exclude, $exclude_sale_items, $rule_id){
|
1292 |
+
global $woocommerce;
|
1293 |
+
$hasExcludeProduct = $quantity = $alreadyExists = 0;
|
1294 |
+
if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
|
1295 |
+
if(count($woocommerce->cart->cart_contents)){
|
1296 |
+
foreach ($woocommerce->cart->cart_contents as $cartItem) {
|
1297 |
+
$is_exclude_sale_items = $this->isItemInSaleItems($exclude_sale_items, $cartItem['data']);
|
1298 |
+
if($is_exclude_sale_items){
|
1299 |
+
continue;
|
1300 |
+
}
|
1301 |
+
$product_id = FlycartWoocommerceProduct::get_id($cartItem['data']);
|
1302 |
+
if($hasExcludeProduct){
|
1303 |
+
if(in_array($product_id, $product_to_exclude)){
|
1304 |
+
continue;
|
1305 |
+
}
|
1306 |
+
}
|
1307 |
+
if(isset(self::$product_attributes[$rule_id])){
|
1308 |
+
if(isset(self::$product_attributes[$rule_id][$product_id])){
|
1309 |
+
$alreadyExists = 1;
|
1310 |
+
$hasAttribute = self::$product_attributes[$rule_id][$product_id];
|
1311 |
+
}
|
1312 |
+
}
|
1313 |
+
if(!$alreadyExists){
|
1314 |
+
$hasAttribute = $this->isItemInAttributeList($attribute, $cartItem);
|
1315 |
+
self::$product_attributes[$rule_id][$product_id] = $hasAttribute;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
if($hasAttribute){
|
1319 |
+
$quantity = $quantity + $cartItem['quantity'];
|
1320 |
+
}
|
1321 |
+
}
|
1322 |
+
}
|
1323 |
+
return $quantity;
|
1324 |
+
}
|
1325 |
+
|
1326 |
/**
|
1327 |
* Get quantity of products from all products
|
1328 |
* */
|
1329 |
public function getProductQuantityForCumulativeProducts($item, $product_page, $rules){
|
1330 |
$product_to_exclude = $rules['product_to_exclude'];
|
1331 |
+
$exclude_sale_items = isset($rules['exclude_sale_items']) ? $rules['exclude_sale_items']: 0;
|
1332 |
global $woocommerce;
|
1333 |
$hasExcludeProduct = $quantity = 0;
|
1334 |
if($product_page) $quantity++;
|
1335 |
if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
|
1336 |
if(count($woocommerce->cart->cart_contents)){
|
1337 |
foreach ($woocommerce->cart->cart_contents as $cartItem) {
|
1338 |
+
$is_exclude_sale_items = $this->isItemInSaleItems($exclude_sale_items, $cartItem['data']);
|
1339 |
+
if($is_exclude_sale_items){
|
1340 |
+
continue;
|
1341 |
+
}
|
1342 |
if($hasExcludeProduct){
|
1343 |
$product_id = $cartItem['product_id'];
|
1344 |
if(isset($cartItem['variation_id']) && $cartItem['variation_id']){
|
1650 |
}
|
1651 |
}
|
1652 |
|
1653 |
+
/**
|
1654 |
+
* To Check in sale items.
|
1655 |
+
*
|
1656 |
+
* @param int $rule_exclude_sale_items
|
1657 |
+
* @param $product
|
1658 |
+
* @return bool
|
1659 |
+
*/
|
1660 |
+
public function isItemInSaleItems($rule_exclude_sale_items, $product)
|
1661 |
+
{
|
1662 |
+
if (!$rule_exclude_sale_items) return false;
|
1663 |
+
$sale_price = FlycartWoocommerceProduct::get_sale_price($product);
|
1664 |
+
if($sale_price > 0) return true;
|
1665 |
+
|
1666 |
+
return false;
|
1667 |
+
}
|
1668 |
+
|
1669 |
/**
|
1670 |
* To Check that the items are in specified category.
|
1671 |
*
|
2028 |
return $discount_range;
|
2029 |
}
|
2030 |
|
2031 |
+
/**
|
2032 |
+
* To get purchased product from rule
|
2033 |
+
* */
|
2034 |
+
public function getPurchasedProductsFromRule($rule){
|
2035 |
+
$purchasedProduct = array();
|
2036 |
+
if(!isset($rule->purchase_history_products)) return $purchasedProduct;
|
2037 |
+
if(is_array($rule->purchase_history_products)) $purchasedProduct = $rule->purchase_history_products;
|
2038 |
+
else if(is_string($rule->purchase_history_products)){
|
2039 |
+
$purchasedProduct = json_decode($rule->purchase_history_products);
|
2040 |
+
$purchasedProduct = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($purchasedProduct);
|
2041 |
+
}
|
2042 |
+
if(!is_array($purchasedProduct)){
|
2043 |
+
$purchasedProduct = array();
|
2044 |
+
}
|
2045 |
+
return $purchasedProduct;
|
2046 |
+
}
|
2047 |
+
|
2048 |
/**
|
2049 |
* To get product to exclude
|
2050 |
* */
|
2487 |
);
|
2488 |
|
2489 |
// To handle Woocommerce currency switcher
|
2490 |
+
// global $WOOCS;
|
2491 |
+
// if(isset($WOOCS)){
|
2492 |
+
// if (method_exists($WOOCS, 'get_currencies')){
|
2493 |
+
// $currencies = $WOOCS->get_currencies();
|
2494 |
+
// $amount = $amount / $currencies[$WOOCS->current_currency]['rate'];
|
2495 |
+
// }
|
2496 |
+
// }
|
2497 |
|
2498 |
// Actually adjust price in cart
|
2499 |
// $woocommerce->cart->cart_contents[$item]['data']->price = $amount;
|
2504 |
$run_multiple_strikeout = true;
|
2505 |
$quantity = $cart_item['quantity'];
|
2506 |
foreach ($additional_details as $detail){
|
2507 |
+
if(isset($detail['discount_quantity']))
|
2508 |
if($detail['discount_quantity'] >= $quantity){
|
2509 |
$run_multiple_strikeout = false;
|
2510 |
}
|
2630 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
2631 |
if($discountPrice > 0){
|
2632 |
$price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
|
2633 |
+
$show_original = 0;
|
2634 |
if(FlycartWoocommerceVersion::wcVersion('3.0'))
|
2635 |
+
$price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display, $show_original);
|
2636 |
+
if(!$show_original){
|
2637 |
+
$item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
|
2638 |
+
$item_price = '<span class="cart_price"><del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix() . '</ins></span>';
|
2639 |
+
}
|
2640 |
}
|
2641 |
}
|
2642 |
|
2643 |
return $item_price;
|
2644 |
}
|
2645 |
|
2646 |
+
public function checkForHighestVariantIfExists($product, $price_to_display, &$show_original){
|
2647 |
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
2648 |
$child_prices = array();
|
2649 |
$children = array_filter( array_map( 'wc_get_product', FlycartWoocommerceProduct::get_children($product) ), 'wc_products_array_filter_visible_grouped' );
|
2688 |
} else {
|
2689 |
$price_to_display .= ' - '.$greatestDiscountPrice;
|
2690 |
}
|
2691 |
+
} else {
|
2692 |
+
if($product->is_type(array('variable', 'subscription_variation', 'variable-subscription'))){
|
2693 |
+
if ( ! empty( $child_prices ) ) {
|
2694 |
+
$child_products = array_keys($child_prices);
|
2695 |
+
if(isset($child_products[0])){
|
2696 |
+
$product_new = FlycartWoocommerceProduct::wc_get_product($child_products[0]);
|
2697 |
+
$discountPrice = $this->getDiscountPriceForTheProduct($product_new);
|
2698 |
+
if($discountPrice <= 0){
|
2699 |
+
$show_original = 1;
|
2700 |
+
}
|
2701 |
+
}
|
2702 |
+
}
|
2703 |
+
}
|
2704 |
}
|
2705 |
+
|
2706 |
return $price_to_display;
|
2707 |
}
|
2708 |
|
loader.php
CHANGED
@@ -109,6 +109,7 @@ if(!class_exists('FlycartWooDiscountRules')){
|
|
109 |
add_action('wp_ajax_savePriceRule', array($this->discountBase, 'savePriceRule'));
|
110 |
add_action('wp_ajax_saveCartRule', array($this->discountBase, 'saveCartRule'));
|
111 |
add_action('wp_ajax_saveConfig', array($this->discountBase, 'saveConfig'));
|
|
|
112 |
|
113 |
add_action('wp_ajax_UpdateStatus', array($this->discountBase, 'updateStatus'));
|
114 |
add_action('wp_ajax_RemoveRule', array($this->discountBase, 'removeRule'));
|
109 |
add_action('wp_ajax_savePriceRule', array($this->discountBase, 'savePriceRule'));
|
110 |
add_action('wp_ajax_saveCartRule', array($this->discountBase, 'saveCartRule'));
|
111 |
add_action('wp_ajax_saveConfig', array($this->discountBase, 'saveConfig'));
|
112 |
+
add_action('wp_ajax_loadProductSelectBox', array($this->discountBase, 'loadProductSelectBox'));
|
113 |
|
114 |
add_action('wp_ajax_UpdateStatus', array($this->discountBase, 'updateStatus'));
|
115 |
add_action('wp_ajax_RemoveRule', array($this->discountBase, 'removeRule'));
|
readme.txt
CHANGED
@@ -4,14 +4,14 @@ Donate link: https://flycart.org/
|
|
4 |
Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts, pricing deals
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
11 |
Create simple to complex discount rules, dynamic pricing and discounts for your WooCommerce online store.
|
12 |
== Description ==
|
13 |
|
14 |
-
WooCommerce discount rules helps you to create any type of bulk discounts, dynamic pricing, advanced discounts, percentage discounts for your products. Offer Product quantity based discounts, cart based discounts at a percentage or fixed amount or Buy One and Get one free (BOGO) deals. Increase your sales multifold by offering dynamic pricing and discounts based on categories, products, user roles, cart items and much more.
|
15 |
|
16 |
You can set discounts for product and also for each product variation or attributes. You can also create customer specific, user roles based discounts.
|
17 |
|
@@ -21,26 +21,54 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
21 |
|
22 |
[View Demo](http://demo.flycart.org/woo-discount-rules) | [Documentation with real examples](http://docs.flycart.org/woocommerce-discount-rules) | [Ask Questions](https://www.flycart.org/support) | [PRO version](https://www.flycart.org/products/wordpress/woocommerce-discount-rules) | [Examples](https://www.flycart.org/woocommerce-discount-rules-examples)
|
23 |
|
24 |
-
|
|
|
|
|
25 |
|
26 |
* Percentage based discounts in WooCommerce
|
27 |
-
*
|
28 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
* Dynamic pricing and discounts for WooCommerce
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
* Attribute specific discount (Buy Small size T-shirts and get 10% discount) - PRO feature
|
38 |
* Option to set Discount for All Products or Global Discount
|
39 |
* Discount for customers with specific domains (10% discount for all emails ending with @acme.com)
|
40 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
* Option to show or hide the discounted price
|
42 |
-
* Multiple Discount rules can be created
|
43 |
-
* Set Discount expiry date
|
44 |
* Priority support for PRO version
|
45 |
|
46 |
== Examples ==
|
@@ -52,6 +80,10 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
52 |
* Purchase any 6 items from Category A and get 25% discount on total cart value.
|
53 |
* Purchase 1 product from Category A, 2 Products from Category B and get 20% discount valid from dd/mm/yyyy to dd/mm/yyyy
|
54 |
|
|
|
|
|
|
|
|
|
55 |
= Product Variant Discounts: =
|
56 |
|
57 |
* Get 50% off on Nike T-shirts Small and Large Sizes
|
@@ -60,7 +92,7 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
60 |
|
61 |
= Product Dependant rule: =
|
62 |
|
63 |
-
* Buy Product A and get
|
64 |
* Buy 2 quantities of Product A, 2 quantities of Product and get 30% discount in Product C
|
65 |
* Buy 3 quantities of Product A and get flat $10 off in product B
|
66 |
* Buy a Mobile and get 20% off on headphone
|
@@ -68,18 +100,26 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
68 |
= BOGO deals: =
|
69 |
|
70 |
* Buy one and get one free of the same product
|
71 |
-
* Buy
|
|
|
72 |
* Buy Any 2 items from Category X, and get a Product free from Category B
|
73 |
* Buy X products and get X number of products free
|
74 |
* Buy 3 products from any category, get 1 free. Buy 6 products, get 2 products free....
|
75 |
* Buy 12 products (any or category specific), get X number of cheapest among them free
|
|
|
|
|
76 |
|
77 |
= Cart Discount Rules: =
|
78 |
|
|
|
79 |
* Add two to six products in cart and get flat $30 discount.
|
80 |
* 10% discount for all retailers (User Role specific discount)
|
81 |
* All orders above $500 will get 15% discount – [Video](https://www.youtube.com/watch?v=RSU0zuvx_Yg)
|
82 |
-
* Buy
|
|
|
|
|
|
|
|
|
83 |
|
84 |
= Product Specific Discount =
|
85 |
|
@@ -92,16 +132,31 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
92 |
* Bulk discount based on user role for specific product or product categories.
|
93 |
* Members of Wholesale customers group gets 40% discount, while Retail customers get 5% discount
|
94 |
|
|
|
|
|
|
|
|
|
95 |
= Global Discount Storewide =
|
96 |
|
97 |
* 20% discount on all items in the store till December 25 – [Video](https://www.youtube.com/watch?v=pHst5Ncse8M)
|
98 |
* All Products get 10% discount
|
99 |
|
|
|
|
|
|
|
|
|
|
|
100 |
= Shipping Address Based Discount =
|
101 |
|
102 |
* Flat 25% discount at Cart for Customers from New York
|
103 |
* Customers from California get 10% discount while those from Texas get 5%
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= Adjustment rules =
|
106 |
|
107 |
* Category specific discount on product price
|
@@ -114,7 +169,7 @@ Display the pricing discount table beautifully on the product page. Start sellin
|
|
114 |
* Discount based on First Product
|
115 |
|
116 |
= Conditions based on =
|
117 |
-
Conditions can be based products, categories, customers, customer roles, shipping location and more.
|
118 |
|
119 |
* All products
|
120 |
* Customer purchase history
|
@@ -136,24 +191,6 @@ Conditions can be based products, categories, customers, customer roles, shippin
|
|
136 |
* Line item quantity
|
137 |
* Total cart quantity
|
138 |
|
139 |
-
[PRO version](https://www.flycart.org/products/wordpress/woocommerce-discount-rules)
|
140 |
-
|
141 |
-
= PRO only features =
|
142 |
-
|
143 |
-
* Fixed price discount for Quantity based discount conditions ( Get $9 discount for purchasing over 6 items)
|
144 |
-
* Category specific discount conditions ( Get 25 % off on all items under Summer Collection )
|
145 |
-
* Applying multiple discount rules in a purchase (Get 5% for order above $500 and 10 % for buying more than 6 items)
|
146 |
-
* Cart discounts by sum of item quantities in cart (Order more than 10 items from any category and get 15 % discount)
|
147 |
-
* Cart discounts by selected customers (John gets 25% life time discount. Ellen gets 10 % limited period offer)
|
148 |
-
* Cart discounts by fixed price discounts (Flat $50 discount for all orders today)
|
149 |
-
* Product dependant Rules - Buy Product A, get 10% off on Product B
|
150 |
-
* Buy 3 units of Product A and get flat $25 discount
|
151 |
-
* Add 3 products to the cart and get the Cheapest Item free
|
152 |
-
* Buy any 2 products from Specific category and get a Product Free from Category B
|
153 |
-
* Buy Product A and Product B from Category Electronics and get a free product from category Accessories
|
154 |
-
* Buy any Product from Category Mobile and choose a free product from Category Hard Cases
|
155 |
-
* Option to offer free products only from certain category
|
156 |
-
|
157 |
|
158 |
= Website =
|
159 |
|
@@ -184,6 +221,22 @@ Yes. It is possible to create multiple discount and you can setup any number of
|
|
184 |
|
185 |
Yes. The discount will be displayed in Product page, product details page, cart striking out the Original price.
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
= Will the discount be showed in the invoice ? =
|
188 |
|
189 |
Yes. The discount will be displayed separately in the invoice.
|
@@ -215,11 +268,11 @@ Yes. You can provide buy 1 get 1 offers in your store.
|
|
215 |
|
216 |
In that case, the rule with the higher priority will be applied.
|
217 |
|
218 |
-
= What happens after my license expires ? =
|
219 |
|
220 |
-
You can continue using
|
221 |
|
222 |
-
= What is your refund
|
223 |
|
224 |
We do have a 30-days money back guarantee. If our plugin doesn’t meet your requirements, we can issue a full refund. No compromise in that.
|
225 |
|
@@ -244,6 +297,12 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
244 |
|
245 |
== Changelog ==
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
= 1.6.1 - 22/05/18 =
|
248 |
* Feature - Date and Time picker for start and end date fields
|
249 |
* Fix - Reorder rule if order id already exists
|
4 |
Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts, pricing deals
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.6.2
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
11 |
Create simple to complex discount rules, dynamic pricing and discounts for your WooCommerce online store.
|
12 |
== Description ==
|
13 |
|
14 |
+
WooCommerce discount rules helps you to create any type of bulk discounts, dynamic pricing, advanced discounts, percentage discounts for your products. Offer Product quantity based discounts, cart based discounts at a percentage or fixed amount or Buy One and Get one free (BOGO) deals or discount based on total order. Increase your sales multifold by offering dynamic pricing and discounts based on categories, products, user roles, cart items, purchase history and much more.
|
15 |
|
16 |
You can set discounts for product and also for each product variation or attributes. You can also create customer specific, user roles based discounts.
|
17 |
|
21 |
|
22 |
[View Demo](http://demo.flycart.org/woo-discount-rules) | [Documentation with real examples](http://docs.flycart.org/woocommerce-discount-rules) | [Ask Questions](https://www.flycart.org/support) | [PRO version](https://www.flycart.org/products/wordpress/woocommerce-discount-rules) | [Examples](https://www.flycart.org/woocommerce-discount-rules-examples)
|
23 |
|
24 |
+
== DISCOUNT TYPES AND FEATURES ==
|
25 |
+
|
26 |
+
= Free version features =
|
27 |
|
28 |
* Percentage based discounts in WooCommerce
|
29 |
+
* [Store-wide global discount](http://docs.flycart.org/woocommerce-discount-rules/percentage-discount-examples/storewide-global-discount-for-all-products)
|
30 |
+
* Quantity range based tiered pricing percentage discount (Example: Buy 3 to 7 quantities, get 10%, Buy 8 to 12 quantities, get 20%)
|
31 |
+
* Cart based percentage discount (Example: Spend more than $1000, get 10% discount)
|
32 |
+
* Order total based discount
|
33 |
+
* Number of line items (count) based discount (Example: Purchase 4 different products or variants and get 10% discount)
|
34 |
+
* Exclude selected products from discount rules (product price based rules)
|
35 |
+
* Date based discount (validity)
|
36 |
+
* Show discount table on product pages
|
37 |
+
|
38 |
+
= PRO features =
|
39 |
+
|
40 |
+
(All features of the free version, plus)[PRO version](https://www.flycart.org/products/wordpress/woocommerce-discount-rules):
|
41 |
+
* Fixed price discounts ( Get $9 discount for purchasing over 6 items)
|
42 |
+
* Category specific discount conditions ( Get 25 % off on all items under Summer Collection )
|
43 |
+
* Buy One Get One Free discounts in WooCommerce (BOGO Deals) [Example: Buy 2 get 1 cheapest product free](http://docs.flycart.org/woocommerce-discount-rules/buy-one-get-one-deals/buy-2-and-get-1-cheapest-free-repeat)
|
44 |
* Dynamic pricing and discounts for WooCommerce
|
45 |
+
* [Specific product based discounts (Buy Product A and get 10% discount)](http://docs.flycart.org/woocommerce-discount-rules/percentage-discount-examples/product-specific-discount-get-10-discount-adidas-shoe)
|
46 |
+
* [User role based dynamic pricing and discounts for your WooCommerce store (Example: Wholesale customers get a discounted price)](http://docs.flycart.org/woocommerce-discount-rules/examples/user-role-based-discount-rules)
|
47 |
+
* Dependant product based discounts (Buy Product A and get discount on Product B)
|
48 |
+
* Offer one or more free products (Multiple products could be offered free using a rule)
|
49 |
+
* [Coupon code activated discount rules - The discount will apply after a coupon is entered.](http://docs.flycart.org/woocommerce-discount-rules/examples/activate-discount-rule-using-a-coupon-code-in-woocommerce)
|
50 |
+
* Option to set discount for each product variant.
|
51 |
+
* Attribute specific discount (Buy Small size T-shirts and get 10% discount)
|
|
|
52 |
* Option to set Discount for All Products or Global Discount
|
53 |
* Discount for customers with specific domains (10% discount for all emails ending with @acme.com)
|
54 |
+
* Customer specific discount (10% discount for selected customers)
|
55 |
+
* [Shipping / Delivery location based discount (Example: If shipping destination is California, get 15% discount)](http://docs.flycart.org/woocommerce-discount-rules/cart-based-discount-examples/customer-shipping-address-based-discount)
|
56 |
+
* Purchase history based discount (Customers who spent $100 in previously get 10% discount)
|
57 |
+
* Discount based on the number of orders placed earlier (Example: 10% discount for customers with 5 or more orders)
|
58 |
+
* If customer purchased selected products previously, he can get a discount (Example: Customers who purchased Shoes get 10% discount)
|
59 |
+
* Applying multiple discount rules in a purchase (Get 5% for order above $500 and 10 % for buying more than 6 items)
|
60 |
+
* Cart discounts by sum of item quantities in cart (Order more than 10 items from any category and get 15 % discount)
|
61 |
+
* Cart discounts by selected customers (John gets 25% life time discount. Ellen gets 10 % limited period offer)
|
62 |
+
* Cart discounts by fixed price discounts (Flat $50 discount for all orders today)
|
63 |
+
* Buy 3 units of Product A and get flat $25 discount
|
64 |
+
* Add 3 products to the cart and get the Cheapest Item free
|
65 |
+
* [Buy any 10 products from Specific category and get a Product Free from Category B](http://docs.flycart.org/woocommerce-discount-rules/buy-one-get-one-deals/buy-any-10-items-from-category-a-and-get-25-discount-on-category-b)
|
66 |
+
* Buy Product A and Product B from Category Electronics and get a free product from category Accessories
|
67 |
+
* Buy any Product from Category Mobile and choose a free product from Category Hard Cases
|
68 |
+
* Option to offer free products only from certain category
|
69 |
+
* Exclude products on SALE from discount rules
|
70 |
+
* SALE Badge for discounted products (When the rules match)
|
71 |
* Option to show or hide the discounted price
|
|
|
|
|
72 |
* Priority support for PRO version
|
73 |
|
74 |
== Examples ==
|
80 |
* Purchase any 6 items from Category A and get 25% discount on total cart value.
|
81 |
* Purchase 1 product from Category A, 2 Products from Category B and get 20% discount valid from dd/mm/yyyy to dd/mm/yyyy
|
82 |
|
83 |
+
= Quantity range based tiered pricing discounts =
|
84 |
+
* [Buy 1 to 5 quantities, get $2 discount, Buy 6 or more, get $3 discount](http://docs.flycart.org/woocommerce-discount-rules/fixed-price-discount-examples/buy-1-to-5-quantity-with-2-discount-buy-6-and-more-with-3-discount-bulk-quantity-discounts)
|
85 |
+
* Buy 2 to 3 quantities, get 10% discount, 4-5 quantities, get 20%, 6-8, get 30%
|
86 |
+
|
87 |
= Product Variant Discounts: =
|
88 |
|
89 |
* Get 50% off on Nike T-shirts Small and Large Sizes
|
92 |
|
93 |
= Product Dependant rule: =
|
94 |
|
95 |
+
* [Buy Product A at full price and get 20% discount in Product B](http://docs.flycart.org/woocommerce-discount-rules/buy-one-get-one-deals/buy-product-a-at-full-price-and-get-product-b-at-20-discount)
|
96 |
* Buy 2 quantities of Product A, 2 quantities of Product and get 30% discount in Product C
|
97 |
* Buy 3 quantities of Product A and get flat $10 off in product B
|
98 |
* Buy a Mobile and get 20% off on headphone
|
100 |
= BOGO deals: =
|
101 |
|
102 |
* Buy one and get one free of the same product
|
103 |
+
* Buy 2 get one cheapest free offer (repeat)
|
104 |
+
* Buy X get Y product free Eg: Buy 3 product and get a pendrive free (or with 50% discount)
|
105 |
* Buy Any 2 items from Category X, and get a Product free from Category B
|
106 |
* Buy X products and get X number of products free
|
107 |
* Buy 3 products from any category, get 1 free. Buy 6 products, get 2 products free....
|
108 |
* Buy 12 products (any or category specific), get X number of cheapest among them free
|
109 |
+
* Free products can be a few selected products, cheapest products in the entire store or from selected categories.
|
110 |
+
* Products can be offered either free (100% discount) or a limited percentage discount (50%)
|
111 |
|
112 |
= Cart Discount Rules: =
|
113 |
|
114 |
+
* [All Orders above $500 will get 15% discount](http://docs.flycart.org/woocommerce-discount-rules/cart-based-discount-examples/all-orders-above-500-will-get-15-discount)
|
115 |
* Add two to six products in cart and get flat $30 discount.
|
116 |
* 10% discount for all retailers (User Role specific discount)
|
117 |
* All orders above $500 will get 15% discount – [Video](https://www.youtube.com/watch?v=RSU0zuvx_Yg)
|
118 |
+
* [Buy 2 products and get 20% discount](http://docs.flycart.org/woocommerce-discount-rules/percentage-discount-examples/order-more-than-2-items-and-get-20-discount) – [Video](https://www.youtube.com/watch?v=84VL6Wwf1DI&t=15s)
|
119 |
+
* Discount for products from specific categories only
|
120 |
+
* Free shipping for orders above $100
|
121 |
+
* Coupon code activated cart discount rules
|
122 |
+
* Discount based on total order
|
123 |
|
124 |
= Product Specific Discount =
|
125 |
|
132 |
* Bulk discount based on user role for specific product or product categories.
|
133 |
* Members of Wholesale customers group gets 40% discount, while Retail customers get 5% discount
|
134 |
|
135 |
+
= Discount rules activated by coupon =
|
136 |
+
|
137 |
+
* Activate / Trigger a discount rule upon entering a coupon code (useful when you want to provide discount to a target group of users)
|
138 |
+
|
139 |
= Global Discount Storewide =
|
140 |
|
141 |
* 20% discount on all items in the store till December 25 – [Video](https://www.youtube.com/watch?v=pHst5Ncse8M)
|
142 |
* All Products get 10% discount
|
143 |
|
144 |
+
= Attributes specific discount =
|
145 |
+
|
146 |
+
* Discount based on the product attributes (NOTE: The attributes should be defined at Product -> Attributes)
|
147 |
+
* Example: 10% discount for purchase of T-Shirt with Small sizes.
|
148 |
+
|
149 |
= Shipping Address Based Discount =
|
150 |
|
151 |
* Flat 25% discount at Cart for Customers from New York
|
152 |
* Customers from California get 10% discount while those from Texas get 5%
|
153 |
|
154 |
+
= Purchase history based discount =
|
155 |
+
|
156 |
+
* Discount based on the total amount spent by the customer in previous orders
|
157 |
+
* Discount based on the total number of orders placed by the customer
|
158 |
+
* Based on purchase history (Example: Provide 10% discount to all customers who purchased Shoes earlier)
|
159 |
+
|
160 |
= Adjustment rules =
|
161 |
|
162 |
* Category specific discount on product price
|
169 |
* Discount based on First Product
|
170 |
|
171 |
= Conditions based on =
|
172 |
+
Conditions can be based products, categories, customers, customer roles, shipping location, coupons, purchase history, order total amount, items in cart and more.
|
173 |
|
174 |
* All products
|
175 |
* Customer purchase history
|
191 |
* Line item quantity
|
192 |
* Total cart quantity
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
= Website =
|
196 |
|
221 |
|
222 |
Yes. The discount will be displayed in Product page, product details page, cart striking out the Original price.
|
223 |
|
224 |
+
= Is it possible to exclude products on SALE? =
|
225 |
+
|
226 |
+
Yes. You can exclude the products on sale from the discount rules.
|
227 |
+
|
228 |
+
= Can I offer a discount based on the purchase history of the customer? =
|
229 |
+
|
230 |
+
Yes. You can offer a discount based on the purchase history, total amount spent by the customer in his previous orders or based on the total number of orders placed by a customer.
|
231 |
+
|
232 |
+
= Is it possible to provide discount for wholesale customers? =
|
233 |
+
|
234 |
+
Yes. The plugin has a user role specific discount rule. You can create a discount for specific user roles like Wholesale customers.
|
235 |
+
|
236 |
+
= How to provide a bulk discount in WooCommerce? =
|
237 |
+
|
238 |
+
Simple. Just install the plugin and create a product price based discount rule. You can configure bulk purchase quantity ranges with discount percentages. Example: 3 to 5 quantities - 10%, 6 to 10 quantities - 20%
|
239 |
+
|
240 |
= Will the discount be showed in the invoice ? =
|
241 |
|
242 |
Yes. The discount will be displayed separately in the invoice.
|
268 |
|
269 |
In that case, the rule with the higher priority will be applied.
|
270 |
|
271 |
+
= What happens after my PRO license expires ? =
|
272 |
|
273 |
+
You can continue using WooCommerce Discount rules plugin in your site. However you won’t be able to receive the Updates and priority support.
|
274 |
|
275 |
+
= What is your refund policy? =
|
276 |
|
277 |
We do have a 30-days money back guarantee. If our plugin doesn’t meet your requirements, we can issue a full refund. No compromise in that.
|
278 |
|
297 |
|
298 |
== Changelog ==
|
299 |
|
300 |
+
= 1.6.2 - 29/05/18 =
|
301 |
+
* Feature - Exclude sale item option(Pro)
|
302 |
+
* Feature - Cumulative option for attributes(Pro)
|
303 |
+
* Feature - Product history based on order count(Pro)
|
304 |
+
* Feature - Product history based on order count in specific product(Pro)
|
305 |
+
|
306 |
= 1.6.1 - 22/05/18 =
|
307 |
* Feature - Date and Time picker for start and end date fields
|
308 |
* Fix - Reorder rule if order id already exists
|
view/includes/sub-menu.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
<?php
|
3 |
$proText = $purchase->getProText();
|
4 |
?>
|
5 |
-
<i><h2
|
6 |
<hr>
|
7 |
<h3 class="nav-tab-wrapper">
|
8 |
-
<a class="nav-tab general_tab" href=javascript:void(0)>
|
9 |
-
<i class="fa fa-tags" style="font-size: 0.8em;"></i>
|
10 |
<a class="nav-tab restriction_tab" href=javascript:void(0)>
|
11 |
-
<i class="fa fa-shopping-cart" style="font-size: 0.8em;"></i>
|
12 |
<a class="nav-tab discount_tab" href=javascript:void(0)>
|
13 |
-
<i class="fa fa-cogs" style="font-size: 0.8em;"></i>
|
14 |
</h3>
|
2 |
<?php
|
3 |
$proText = $purchase->getProText();
|
4 |
?>
|
5 |
+
<i><h2><?php esc_html_e('Woo Discount Rules', 'woo-discount-rules'); ?> <?php echo $proText; ?> <span class="woo-discount-version">v<?php echo WOO_DISCOUNT_VERSION; ?></span></h2></i>
|
6 |
<hr>
|
7 |
<h3 class="nav-tab-wrapper">
|
8 |
+
<a class="nav-tab general_tab nav-tab-active" href=javascript:void(0)>
|
9 |
+
<i class="fa fa-tags" style="font-size: 0.8em;"></i> <?php esc_html_e('General', 'woo-discount-rules'); ?> </a>
|
10 |
<a class="nav-tab restriction_tab" href=javascript:void(0)>
|
11 |
+
<i class="fa fa-shopping-cart" style="font-size: 0.8em;"></i> <?php esc_html_e('Condition', 'woo-discount-rules'); ?> </a>
|
12 |
<a class="nav-tab discount_tab" href=javascript:void(0)>
|
13 |
+
<i class="fa fa-cogs" style="font-size: 0.8em;"></i> <?php esc_html_e('Discount', 'woo-discount-rules'); ?> </a>
|
14 |
</h3>
|
view/settings.php
CHANGED
@@ -11,7 +11,7 @@ if (is_string($data)) $data = json_decode($data, true);
|
|
11 |
$isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
12 |
?>
|
13 |
|
14 |
-
<div class="container-fluid">
|
15 |
<div class="row-fluid">
|
16 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
17 |
<form method="post" id="discount_config">
|
@@ -348,4 +348,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
348 |
<?php } ?>
|
349 |
</form>
|
350 |
</div>
|
|
|
|
|
|
|
351 |
</div>
|
11 |
$isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
12 |
?>
|
13 |
|
14 |
+
<div class="container-fluid woo_discount_loader_outer">
|
15 |
<div class="row-fluid">
|
16 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
17 |
<form method="post" id="discount_config">
|
348 |
<?php } ?>
|
349 |
</form>
|
350 |
</div>
|
351 |
+
<div class="woo_discount_loader">
|
352 |
+
<div class="lds-ripple"><div></div><div></div></div>
|
353 |
+
</div>
|
354 |
</div>
|
view/view-cart-rules.php
CHANGED
@@ -42,7 +42,7 @@ if (empty($discount_rules)) {
|
|
42 |
}
|
43 |
$isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
44 |
?>
|
45 |
-
<div class="container-fluid">
|
46 |
<form id="form_cart_rule">
|
47 |
<div class="row-fluid">
|
48 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-9'; ?>">
|
@@ -125,7 +125,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
125 |
</div>
|
126 |
</div>
|
127 |
|
128 |
-
<div class="col-md-12" id="restriction_block"><h4 class="text text-muted"> <?php esc_html_e('Cart Conditions', 'woo-discount-rules'); ?> </h4>
|
129 |
<a href=javascript:void(0) id="add_cart_rule" class="button button-primary"><i
|
130 |
class="glyphicon glyphicon-plus"></i>
|
131 |
<?php esc_html_e('Add Condition', 'woo-discount-rules'); ?></a>
|
@@ -290,9 +290,29 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
290 |
}
|
291 |
if ($type == 'customer_based_on_purchase_history') { ?> selected=selected <?php } ?>>
|
292 |
<?php if (!$pro) { ?>
|
293 |
-
<?php esc_html_e('
|
294 |
<?php } else { ?>
|
295 |
-
<?php esc_html_e('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
<?php } ?>
|
297 |
</option>
|
298 |
</optgroup>
|
@@ -402,18 +422,37 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
402 |
$class = 'style="display:none"';
|
403 |
$woocommerce_order_status = wc_get_order_statuses();
|
404 |
$purchased_history_amount = '';
|
405 |
-
$
|
406 |
-
|
|
|
407 |
$purchase_history_status_list = isset($discount_rules[$type]['purchase_history_order_status'])? $discount_rules[$type]['purchase_history_order_status'] : array();
|
408 |
$purchased_history_amount = isset($discount_rules[$type]['purchased_history_amount'])? $discount_rules[$type]['purchased_history_amount'] : 0;
|
|
|
409 |
if(empty($purchase_history_status_list)){
|
410 |
$purchase_history_status_list[] = 'wc-completed';
|
411 |
}
|
412 |
$class = 'style="display:block"';
|
413 |
$hit = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
} ?>
|
415 |
<div id="purchase_history_div_<?php echo $i; ?>" <?php echo $class; ?>>
|
416 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
<input name="discount_rule[<?php echo $i; ?>][purchased_history_amount]" value="<?php echo $purchased_history_amount; ?>" type="text"/> <?php esc_html_e('In Order status', 'woo-discount-rules'); ?>
|
418 |
<select class="order_status_list selectpicker"
|
419 |
data-live-search="true"
|
@@ -457,7 +496,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
457 |
</div>
|
458 |
|
459 |
<!-- TODO: Implement ForEach Concept -->
|
460 |
-
<div class="col-md-12" id="discount_block"><h4 class="text text-muted"> <?php esc_html_e('Discount', 'woo-discount-rules'); ?></h4>
|
461 |
<?php
|
462 |
$discount_type = 'percentage_discount';
|
463 |
$to_discount = 0;
|
@@ -529,6 +568,9 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
529 |
<input type="hidden" id="is_pro" value="<?php echo $pro; ?>">
|
530 |
<input type="hidden" id="flycart_wdr_woocommerce_version" value="<?php echo $flycart_wdr_woocommerce_version; ?>">
|
531 |
</form>
|
|
|
|
|
|
|
532 |
</div>
|
533 |
|
534 |
<?php include_once(WOO_DISCOUNT_DIR . '/view/includes/footer.php'); ?>
|
42 |
}
|
43 |
$isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
44 |
?>
|
45 |
+
<div class="container-fluid woo_discount_loader_outer">
|
46 |
<form id="form_cart_rule">
|
47 |
<div class="row-fluid">
|
48 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-9'; ?>">
|
125 |
</div>
|
126 |
</div>
|
127 |
|
128 |
+
<div class="col-md-12 wdr_hide" id="restriction_block"><h4 class="text text-muted"> <?php esc_html_e('Cart Conditions', 'woo-discount-rules'); ?> </h4>
|
129 |
<a href=javascript:void(0) id="add_cart_rule" class="button button-primary"><i
|
130 |
class="glyphicon glyphicon-plus"></i>
|
131 |
<?php esc_html_e('Add Condition', 'woo-discount-rules'); ?></a>
|
290 |
}
|
291 |
if ($type == 'customer_based_on_purchase_history') { ?> selected=selected <?php } ?>>
|
292 |
<?php if (!$pro) { ?>
|
293 |
+
<?php esc_html_e('Purchased amount', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
|
294 |
<?php } else { ?>
|
295 |
+
<?php esc_html_e('Purchased amount', 'woo-discount-rules'); ?>
|
296 |
+
<?php } ?>
|
297 |
+
</option>
|
298 |
+
<option
|
299 |
+
<?php if (!$pro) { ?> disabled <?php } else { ?> value="customer_based_on_purchase_history_order_count" <?php
|
300 |
+
}
|
301 |
+
if ($type == 'customer_based_on_purchase_history_order_count') { ?> selected=selected <?php } ?>>
|
302 |
+
<?php if (!$pro) { ?>
|
303 |
+
<?php esc_html_e('Number of order purchased', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
|
304 |
+
<?php } else { ?>
|
305 |
+
<?php esc_html_e('Number of order purchased', 'woo-discount-rules'); ?>
|
306 |
+
<?php } ?>
|
307 |
+
</option>
|
308 |
+
<option
|
309 |
+
<?php if (!$pro) { ?> disabled <?php } else { ?> value="customer_based_on_purchase_history_product_order_count" <?php
|
310 |
+
}
|
311 |
+
if ($type == 'customer_based_on_purchase_history_product_order_count') { ?> selected=selected <?php } ?>>
|
312 |
+
<?php if (!$pro) { ?>
|
313 |
+
<?php esc_html_e('Number of order purchased in products', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
|
314 |
+
<?php } else { ?>
|
315 |
+
<?php esc_html_e('Number of order purchased in products', 'woo-discount-rules'); ?>
|
316 |
<?php } ?>
|
317 |
</option>
|
318 |
</optgroup>
|
422 |
$class = 'style="display:none"';
|
423 |
$woocommerce_order_status = wc_get_order_statuses();
|
424 |
$purchased_history_amount = '';
|
425 |
+
$purchased_history_type = 'atleast';
|
426 |
+
$purchase_history_status_list = $product_purchase_history_list = array();
|
427 |
+
if ($type == 'customer_based_on_purchase_history' || $type == 'customer_based_on_purchase_history_order_count' || $type == 'customer_based_on_purchase_history_product_order_count') {
|
428 |
$purchase_history_status_list = isset($discount_rules[$type]['purchase_history_order_status'])? $discount_rules[$type]['purchase_history_order_status'] : array();
|
429 |
$purchased_history_amount = isset($discount_rules[$type]['purchased_history_amount'])? $discount_rules[$type]['purchased_history_amount'] : 0;
|
430 |
+
$purchased_history_type = isset($discount_rules[$type]['purchased_history_type'])? $discount_rules[$type]['purchased_history_type'] : 'atleast';
|
431 |
if(empty($purchase_history_status_list)){
|
432 |
$purchase_history_status_list[] = 'wc-completed';
|
433 |
}
|
434 |
$class = 'style="display:block"';
|
435 |
$hit = true;
|
436 |
+
$purchase_history_products = isset($discount_rules[$type]['purchase_history_products'])? $discount_rules[$type]['purchase_history_products'] : array();
|
437 |
+
if(isset($purchase_history_products)){
|
438 |
+
if(is_array($purchase_history_products))
|
439 |
+
$product_purchase_history_list = $purchase_history_products;
|
440 |
+
else
|
441 |
+
$product_purchase_history_list = json_decode((isset($purchase_history_products) ? $purchase_history_products : '{}'), true);
|
442 |
+
} else {
|
443 |
+
$product_purchase_history_list = array();
|
444 |
+
}
|
445 |
} ?>
|
446 |
<div id="purchase_history_div_<?php echo $i; ?>" <?php echo $class; ?>>
|
447 |
+
<div class="form-group<?php echo ($type == 'customer_based_on_purchase_history_product_order_count')? '': ' wdr_hide';?>" id="purchase_history_products_list_<?php echo $i; ?>">
|
448 |
+
<?php
|
449 |
+
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_purchase_history_list, 'discount_rule['.$i.'][purchase_history_products]');
|
450 |
+
?>
|
451 |
+
</div>
|
452 |
+
<select class="selectpicker purchased_history_type" name="discount_rule[<?php echo $i; ?>][purchased_history_type]">
|
453 |
+
<option value="atleast"<?php echo ($purchased_history_type == 'atleast')? ' selected="selected"': ''; ?>><?php esc_html_e('Greater than or equal to', 'woo-discount-rules'); ?></option>
|
454 |
+
<option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
|
455 |
+
</select>
|
456 |
<input name="discount_rule[<?php echo $i; ?>][purchased_history_amount]" value="<?php echo $purchased_history_amount; ?>" type="text"/> <?php esc_html_e('In Order status', 'woo-discount-rules'); ?>
|
457 |
<select class="order_status_list selectpicker"
|
458 |
data-live-search="true"
|
496 |
</div>
|
497 |
|
498 |
<!-- TODO: Implement ForEach Concept -->
|
499 |
+
<div class="col-md-12 wdr_hide" id="discount_block"><h4 class="text text-muted"> <?php esc_html_e('Discount', 'woo-discount-rules'); ?></h4>
|
500 |
<?php
|
501 |
$discount_type = 'percentage_discount';
|
502 |
$to_discount = 0;
|
568 |
<input type="hidden" id="is_pro" value="<?php echo $pro; ?>">
|
569 |
<input type="hidden" id="flycart_wdr_woocommerce_version" value="<?php echo $flycart_wdr_woocommerce_version; ?>">
|
570 |
</form>
|
571 |
+
<div class="woo_discount_loader">
|
572 |
+
<div class="lds-ripple"><div></div><div></div></div>
|
573 |
+
</div>
|
574 |
</div>
|
575 |
|
576 |
<?php include_once(WOO_DISCOUNT_DIR . '/view/includes/footer.php'); ?>
|
view/view-pricing-rules.php
CHANGED
@@ -26,7 +26,7 @@ if($isPro){
|
|
26 |
$attributes = FlycartWooDiscountRulesAdvancedHelper::get_all_product_attributes();
|
27 |
}
|
28 |
?>
|
29 |
-
<div class="container-fluid">
|
30 |
<form id="form_price_rule">
|
31 |
<div class="row-fluid">
|
32 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
@@ -119,10 +119,10 @@ if($isPro){
|
|
119 |
?>
|
120 |
<div class="form-inline">
|
121 |
<input type="text"
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
<input type="text" name="date_to"
|
127 |
class="form-control datepicker"
|
128 |
value="<?php echo $date_to; ?>"
|
@@ -135,7 +135,7 @@ if($isPro){
|
|
135 |
</div>
|
136 |
</div>
|
137 |
|
138 |
-
<div class="col-md-12" id="restriction_block"><h4 class="text text-muted"> <?php esc_html_e('Discount Conditions', 'woo-discount-rules'); ?></h4>
|
139 |
<hr>
|
140 |
<div class="qty_based_condition_cont price_discount_condition_con">
|
141 |
<div class="form-group">
|
@@ -205,27 +205,55 @@ if($isPro){
|
|
205 |
value="<?php echo $value['id']; ?>"<?php if (in_array($value['id'], $attribute_list)) { ?> selected=selected <?php } ?>><?php echo $value['text']; ?></option>
|
206 |
<?php } ?>
|
207 |
</select>
|
|
|
|
|
|
|
|
|
208 |
</div>
|
209 |
</div>
|
210 |
</div>
|
211 |
</div>
|
212 |
|
213 |
<div class="form-group" id="product_exclude_list">
|
214 |
-
<div class="
|
215 |
-
<div class="
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
if(
|
220 |
-
$
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
226 |
|
227 |
-
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
</div>
|
230 |
</div>
|
231 |
</div>
|
@@ -306,7 +334,7 @@ if($isPro){
|
|
306 |
</span>
|
307 |
<input class="form-control coupons_to_apply" id="coupons_to_apply" name="coupons_to_apply" value="<?php echo $coupons_to_apply; ?>"/>
|
308 |
</div>
|
309 |
-
|
310 |
} else {
|
311 |
?>
|
312 |
<div class="woo-support-in_pro">
|
@@ -374,9 +402,12 @@ if($isPro){
|
|
374 |
<?php
|
375 |
if($pro){
|
376 |
?>
|
377 |
-
<
|
378 |
-
|
379 |
-
|
|
|
|
|
|
|
380 |
<?php
|
381 |
} else {
|
382 |
?>
|
@@ -387,33 +418,48 @@ if($isPro){
|
|
387 |
</div>
|
388 |
<?php
|
389 |
}
|
390 |
-
|
391 |
-
<div class="form-group" id="based_on_purchase_history_fields">
|
392 |
-
<?php
|
393 |
-
$purchased_history_amount = (isset($data->purchased_history_amount) ? $data->purchased_history_amount : 0);
|
394 |
-
$purchased_history_type = (isset($data->purchased_history_type) ? $data->purchased_history_type : 'atleast');
|
395 |
-
?>
|
396 |
-
<label><?php esc_html_e('Total purchased amount ', 'woo-discount-rules'); ?></label>
|
397 |
-
<select class="selectpicker purchased_history_type" name="purchased_history_type">
|
398 |
-
<option value="atleast"<?php echo ($purchased_history_type == 'atleast')? ' selected="selected"': ''; ?>><?php esc_html_e('Greater than or equal to', 'woo-discount-rules'); ?></option>
|
399 |
-
<option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
|
400 |
-
</select>
|
401 |
-
<input type="text" value="<?php echo $purchased_history_amount; ?>" name="purchased_history_amount"/>
|
402 |
-
<label><?php esc_html_e('In Order status', 'woo-discount-rules'); ?></label>
|
403 |
-
<?php
|
404 |
-
$woocommerce_order_status = wc_get_order_statuses();
|
405 |
-
$purchase_history_status_list = json_decode((isset($data->purchase_history_status_list) ? $data->purchase_history_status_list : '{}'), true);
|
406 |
-
if(empty($purchase_history_status_list)){
|
407 |
-
$purchase_history_status_list[] = 'wc-completed';
|
408 |
-
}
|
409 |
?>
|
410 |
-
<
|
411 |
-
<?php
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
</div>
|
418 |
</div>
|
419 |
</div>
|
@@ -477,7 +523,7 @@ if($isPro){
|
|
477 |
</div>
|
478 |
</div>
|
479 |
<!-- TODO: Implement ForEach Concept -->
|
480 |
-
<div class="col-md-12" id="discount_block">
|
481 |
<h4 class="text text-muted"> <?php esc_html_e('Discount', 'woo-discount-rules'); ?></h4>
|
482 |
<div class="qty_based_discount_cont price_discounts_con">
|
483 |
<a href=javascript:void(0) class="button button-primary" id="addNewDiscountRange"><i
|
@@ -633,7 +679,7 @@ if($isPro){
|
|
633 |
</div>
|
634 |
</label>
|
635 |
<label><a href=javascript:void(0)
|
636 |
-
|
637 |
|
638 |
</div>
|
639 |
</div>
|
@@ -659,21 +705,24 @@ if($isPro){
|
|
659 |
</div>
|
660 |
</div>
|
661 |
</div>
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
|
|
676 |
</form>
|
|
|
|
|
|
|
677 |
</div>
|
678 |
-
|
679 |
<?php include_once(WOO_DISCOUNT_DIR . '/view/includes/footer.php'); ?>
|
26 |
$attributes = FlycartWooDiscountRulesAdvancedHelper::get_all_product_attributes();
|
27 |
}
|
28 |
?>
|
29 |
+
<div class="container-fluid woo_discount_loader_outer">
|
30 |
<form id="form_price_rule">
|
31 |
<div class="row-fluid">
|
32 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
119 |
?>
|
120 |
<div class="form-inline">
|
121 |
<input type="text"
|
122 |
+
name="date_from"
|
123 |
+
class="form-control datepicker"
|
124 |
+
value="<?php echo $date_from; ?>"
|
125 |
+
placeholder="<?php esc_attr_e('From', 'woo-discount-rules'); ?>">
|
126 |
<input type="text" name="date_to"
|
127 |
class="form-control datepicker"
|
128 |
value="<?php echo $date_to; ?>"
|
135 |
</div>
|
136 |
</div>
|
137 |
|
138 |
+
<div class="col-md-12 wdr_hide" id="restriction_block"><h4 class="text text-muted"> <?php esc_html_e('Discount Conditions', 'woo-discount-rules'); ?></h4>
|
139 |
<hr>
|
140 |
<div class="qty_based_condition_cont price_discount_condition_con">
|
141 |
<div class="form-group">
|
205 |
value="<?php echo $value['id']; ?>"<?php if (in_array($value['id'], $attribute_list)) { ?> selected=selected <?php } ?>><?php echo $value['text']; ?></option>
|
206 |
<?php } ?>
|
207 |
</select>
|
208 |
+
<?php $is_cumulative_attribute = (isset($data->is_cumulative_attribute))? $data->is_cumulative_attribute : 0 ?>
|
209 |
+
<div class="form-group">
|
210 |
+
<input type="checkbox" name="is_cumulative_attribute" id="is_cumulative_attribute" value="1" <?php if($is_cumulative_attribute) { echo "checked"; } ?>> <label class="checkbox_label" for="is_cumulative_attribute"><?php esc_html_e('Check this box to count quantities cumulatively across attribute', 'woo-discount-rules'); ?></label>
|
211 |
+
</div>
|
212 |
</div>
|
213 |
</div>
|
214 |
</div>
|
215 |
</div>
|
216 |
|
217 |
<div class="form-group" id="product_exclude_list">
|
218 |
+
<div class="form-group">
|
219 |
+
<div class="row">
|
220 |
+
<div class="col-md-3"><label><?php esc_html_e('Exclude products', 'woo-discount-rules'); ?></label></div>
|
221 |
+
<div class="col-md-9">
|
222 |
+
<?php
|
223 |
+
if(isset($data->product_to_exclude)){
|
224 |
+
if(is_array($data->product_to_exclude))
|
225 |
+
$product_exclude_list = $data->product_to_exclude;
|
226 |
+
else
|
227 |
+
$product_exclude_list = json_decode((isset($data->product_to_exclude) ? $data->product_to_exclude : '{}'), true);
|
228 |
+
} else {
|
229 |
+
$product_exclude_list = array();
|
230 |
+
}
|
231 |
|
232 |
+
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_exclude_list, 'product_to_exclude');
|
233 |
+
?>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
<div class="form-group">
|
238 |
+
<div class="row">
|
239 |
+
<div class="col-md-3"><label for="exclude_sale_items"><?php esc_html_e('Exclude sale items', 'woo-discount-rules'); ?></label></div>
|
240 |
+
<div class="col-md-9">
|
241 |
+
<?php
|
242 |
+
if($pro){
|
243 |
+
$exclude_sale_items = (isset($data->exclude_sale_items))? $data->exclude_sale_items : 0; ?>
|
244 |
+
<input type="checkbox" name="exclude_sale_items" id="exclude_sale_items" value="1" <?php if($exclude_sale_items) { echo "checked"; } ?>> <label class="checkbox_label" for="exclude_sale_items"><?php esc_html_e('Check this box if the rule should not apply to items on sale.', 'woo-discount-rules'); ?></label>
|
245 |
+
<?php
|
246 |
+
} else {
|
247 |
+
?>
|
248 |
+
<div class="woo-support-in_pro">
|
249 |
+
<?php
|
250 |
+
esc_html_e('Supported in PRO version', 'woo-discount-rules');
|
251 |
+
?>
|
252 |
+
</div>
|
253 |
+
<?php
|
254 |
+
}
|
255 |
+
?>
|
256 |
+
</div>
|
257 |
</div>
|
258 |
</div>
|
259 |
</div>
|
334 |
</span>
|
335 |
<input class="form-control coupons_to_apply" id="coupons_to_apply" name="coupons_to_apply" value="<?php echo $coupons_to_apply; ?>"/>
|
336 |
</div>
|
337 |
+
<?php
|
338 |
} else {
|
339 |
?>
|
340 |
<div class="woo-support-in_pro">
|
402 |
<?php
|
403 |
if($pro){
|
404 |
?>
|
405 |
+
<select class="selectpicker" id="based_on_purchase_history" name="based_on_purchase_history">
|
406 |
+
<option value="0"<?php if ($based_on_purchase_history == '0') { ?> selected=selected <?php } ?>><?php esc_html_e('Do not use', 'woo-discount-rules'); ?></option>
|
407 |
+
<option value="1"<?php if ($based_on_purchase_history == '1') { ?> selected=selected <?php } ?>><?php esc_html_e('Purchased amount', 'woo-discount-rules'); ?></option>
|
408 |
+
<option value="2"<?php if ($based_on_purchase_history == '2') { ?> selected=selected <?php } ?>><?php esc_html_e('Number of orders', 'woo-discount-rules'); ?></option>
|
409 |
+
<option value="3"<?php if ($based_on_purchase_history == '3') { ?> selected=selected <?php } ?>><?php esc_html_e('Purchased product', 'woo-discount-rules'); ?></option>
|
410 |
+
</select>
|
411 |
<?php
|
412 |
} else {
|
413 |
?>
|
418 |
</div>
|
419 |
<?php
|
420 |
}
|
421 |
+
if($pro){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
?>
|
423 |
+
<div class="form-group" id="based_on_purchase_history_fields">
|
424 |
+
<?php
|
425 |
+
$purchased_history_amount = (isset($data->purchased_history_amount) ? $data->purchased_history_amount : 0);
|
426 |
+
$purchased_history_type = (isset($data->purchased_history_type) ? $data->purchased_history_type : 'atleast');
|
427 |
+
?>
|
428 |
+
<div class="form-group wdr_hide" id="purchase_history_products">
|
429 |
+
<?php
|
430 |
+
if(isset($data->purchase_history_products)){
|
431 |
+
if(is_array($data->purchase_history_products))
|
432 |
+
$product_purchase_history_list = $data->purchase_history_products;
|
433 |
+
else
|
434 |
+
$product_purchase_history_list = json_decode((isset($data->purchase_history_products) ? $data->purchase_history_products : '{}'), true);
|
435 |
+
} else {
|
436 |
+
$product_purchase_history_list = array();
|
437 |
+
}
|
438 |
+
|
439 |
+
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_purchase_history_list, 'purchase_history_products');
|
440 |
+
?>
|
441 |
+
</div>
|
442 |
+
<select class="selectpicker purchased_history_type" name="purchased_history_type">
|
443 |
+
<option value="atleast"<?php echo ($purchased_history_type == 'atleast')? ' selected="selected"': ''; ?>><?php esc_html_e('Greater than or equal to', 'woo-discount-rules'); ?></option>
|
444 |
+
<option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
|
445 |
+
</select>
|
446 |
+
<input type="text" value="<?php echo $purchased_history_amount; ?>" name="purchased_history_amount"/>
|
447 |
+
<label><?php esc_html_e('In Order status', 'woo-discount-rules'); ?></label>
|
448 |
+
<?php
|
449 |
+
$woocommerce_order_status = wc_get_order_statuses();
|
450 |
+
$purchase_history_status_list = json_decode((isset($data->purchase_history_status_list) ? $data->purchase_history_status_list : '{}'), true);
|
451 |
+
if(empty($purchase_history_status_list)){
|
452 |
+
$purchase_history_status_list[] = 'wc-completed';
|
453 |
+
}
|
454 |
+
?>
|
455 |
+
<select class="purchase_history_status_list selectpicker" multiple name="purchase_history_status_list[]">
|
456 |
+
<?php foreach ($woocommerce_order_status as $index => $value) { ?>
|
457 |
+
<option
|
458 |
+
value="<?php echo $index; ?>"<?php if (in_array($index, $purchase_history_status_list)) { ?> selected=selected <?php } ?>><?php echo $value; ?></option>
|
459 |
+
<?php } ?>
|
460 |
+
</select>
|
461 |
+
</div>
|
462 |
+
<?php } ?>
|
463 |
</div>
|
464 |
</div>
|
465 |
</div>
|
523 |
</div>
|
524 |
</div>
|
525 |
<!-- TODO: Implement ForEach Concept -->
|
526 |
+
<div class="col-md-12 wdr_hide" id="discount_block">
|
527 |
<h4 class="text text-muted"> <?php esc_html_e('Discount', 'woo-discount-rules'); ?></h4>
|
528 |
<div class="qty_based_discount_cont price_discounts_con">
|
529 |
<a href=javascript:void(0) class="button button-primary" id="addNewDiscountRange"><i
|
679 |
</div>
|
680 |
</label>
|
681 |
<label><a href=javascript:void(0)
|
682 |
+
class="btn btn-danger form-control remove_discount_range"><?php esc_html_e('Remove', 'woo-discount-rules'); ?></a></label>
|
683 |
|
684 |
</div>
|
685 |
</div>
|
705 |
</div>
|
706 |
</div>
|
707 |
</div>
|
708 |
+
</div>
|
709 |
+
<?php if(!$isPro){ ?>
|
710 |
+
<div class="col-md-1"></div>
|
711 |
+
<!-- Sidebar -->
|
712 |
+
<?php include_once(__DIR__ . '/template/sidebar.php'); ?>
|
713 |
+
<!-- Sidebar END -->
|
714 |
+
<?php } ?>
|
715 |
+
<input type="hidden" name="rule_id" id="rule_id" value="<?php echo $rule_id; ?>">
|
716 |
+
<input type="hidden" name="form" value="<?php echo $form; ?>">
|
717 |
+
<input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php'); ?>">
|
718 |
+
<input type="hidden" id="admin_path"
|
719 |
+
value="<?php echo admin_url('admin.php?page=woo_discount_rules'); ?>">
|
720 |
+
<input type="hidden" id="pro_suffix" value="<?php echo $suffix; ?>">
|
721 |
+
<input type="hidden" id="is_pro" value="<?php echo $pro; ?>">
|
722 |
+
<input type="hidden" id="flycart_wdr_woocommerce_version" value="<?php echo $flycart_wdr_woocommerce_version; ?>">
|
723 |
</form>
|
724 |
+
<div class="woo_discount_loader">
|
725 |
+
<div class="lds-ripple"><div></div><div></div></div>
|
726 |
+
</div>
|
727 |
</div>
|
|
|
728 |
<?php include_once(WOO_DISCOUNT_DIR . '/view/includes/footer.php'); ?>
|
woo-discount-rules.php
CHANGED
@@ -5,13 +5,13 @@
|
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 1.6.
|
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: 2.4
|
14 |
-
* WC tested up to: 3.
|
15 |
*/
|
16 |
|
17 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 1.6.2
|
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: 2.4
|
14 |
+
* WC tested up to: 3.4
|
15 |
*/
|
16 |
|
17 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly
|