Version Description
- 08/02/18 =
- Feature - Buy any or more products and get 10% discount in one or more cheapest (Pro)
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.4.44 |
Comparing to | |
See all releases |
Code changes from version 1.4.43 to 1.4.44
- assets/css/style.css +1 -1
- assets/js/app.js +23 -5
- includes/pricing-rules.php +46 -23
- readme.txt +5 -2
- view/cart-rules.php +74 -67
- view/includes/footer.php +7 -0
- view/pricing-rules.php +71 -66
- view/template/sidebar.php +4 -0
- view/view-pricing-rules.php +18 -0
- woo-discount-rules.php +1 -1
assets/css/style.css
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
font-style: italic;
|
43 |
color: #999;
|
44 |
}
|
45 |
-
.discount_product_option_list_con, .discount_product_option_more_cheapest_con{
|
46 |
display: inline-block;
|
47 |
}
|
48 |
.rule_buttons_con{
|
42 |
font-style: italic;
|
43 |
color: #999;
|
44 |
}
|
45 |
+
.discount_product_option_list_con, .discount_product_option_more_cheapest_con, .discount_product_percent_con{
|
46 |
display: inline-block;
|
47 |
}
|
48 |
.rule_buttons_con{
|
assets/js/app.js
CHANGED
@@ -142,7 +142,7 @@ function validateFields(){
|
|
142 |
'<option value="percentage_discount"> Percentage Discount </option> <option value="price_discount">Price Discount </option> <option value="product_discount">Product Discount </option> </select></label> <label>Value ' +
|
143 |
'<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
|
144 |
form += '<div class="price_discount_product_list_con hide">' +
|
145 |
-
' Apply for <select class="selectpicker discount_product_option" name="discount_range['+count+'][discount_product_option]"><option value="all">All selected</option><option value="any_cheapest">Any one cheapest from selected</option><option value="any_cheapest_from_all">Any one cheapest from all products</option><option value="more_than_one_cheapest">More than one cheapest from selected</option>' +
|
146 |
'</select>';
|
147 |
form += '<div class="discount_product_option_more_cheapest_con hide">';
|
148 |
form += '<label>Item count<input type="text" name="discount_range['+count+'][discount_product_items]" class="form-control" value="" placeholder="ex. 1" /></label>';
|
@@ -155,8 +155,12 @@ function validateFields(){
|
|
155 |
form += '<select class="wc-product-search" multiple="multiple" style="width: 250px" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product…" data-action="woocommerce_json_search_products_and_variations"></select>'
|
156 |
}
|
157 |
form += '</div>';
|
|
|
|
|
|
|
158 |
form += '</div>';
|
159 |
-
form += '</
|
|
|
160 |
} else {
|
161 |
var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
|
162 |
'<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control price_discount_type" name="discount_range[' + count + '][discount_type]"> ' +
|
@@ -165,7 +169,7 @@ function validateFields(){
|
|
165 |
form += '<div class="price_discount_product_list_con hide"><select class="product_list selectpicker price_discount_product_list" multiple name="discount_range[' + count + '][discount_product][]">';
|
166 |
form += '<option>none</option>';
|
167 |
form += '</select></div>';
|
168 |
-
form += '</label> <label>Action
|
169 |
}
|
170 |
$('#discount_rule_list').append(form);
|
171 |
$('.product_list,.selectpicker').selectpicker('refresh');
|
@@ -392,13 +396,16 @@ function validateFields(){
|
|
392 |
$(document).on('change', '.price_discount_type', function () {
|
393 |
var discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_amount');
|
394 |
var price_discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_product_list_con');
|
|
|
395 |
if($(this).val() == 'product_discount'){
|
396 |
discount_amount.hide();
|
397 |
price_discount_amount.removeClass('hide').show();
|
|
|
398 |
$('.hide-for-product-discount').hide();
|
399 |
} else {
|
400 |
discount_amount.show();
|
401 |
price_discount_amount.hide();
|
|
|
402 |
$('.hide-for-product-discount').show();
|
403 |
}
|
404 |
});
|
@@ -408,12 +415,12 @@ function validateFields(){
|
|
408 |
$(document).on('change', 'select.discount_product_option', function () {
|
409 |
var discount_product = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_list_con');
|
410 |
var discount_product_more_cheapest = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_more_cheapest_con');
|
411 |
-
if($(this).val() == 'any_cheapest_from_all'){
|
412 |
discount_product.addClass('hide');
|
413 |
} else {
|
414 |
discount_product.removeClass('hide');
|
415 |
}
|
416 |
-
if($(this).val() == 'more_than_one_cheapest'){
|
417 |
discount_product_more_cheapest.removeClass('hide');
|
418 |
} else {
|
419 |
discount_product_more_cheapest.addClass('hide');
|
@@ -421,6 +428,17 @@ function validateFields(){
|
|
421 |
});
|
422 |
$('select.discount_product_option').trigger('change');
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
|
425 |
// Saving Cart Rule.
|
426 |
$('#saveCartRule').on('click', function (event) {
|
142 |
'<option value="percentage_discount"> Percentage Discount </option> <option value="price_discount">Price Discount </option> <option value="product_discount">Product Discount </option> </select></label> <label>Value ' +
|
143 |
'<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
|
144 |
form += '<div class="price_discount_product_list_con hide">' +
|
145 |
+
' Apply for <select class="selectpicker discount_product_option" name="discount_range['+count+'][discount_product_option]"><option value="all">All selected</option><option value="any_cheapest">Any one cheapest from selected</option><option value="any_cheapest_from_all">Any one cheapest from all products</option><option value="more_than_one_cheapest">More than one cheapest from selected</option><option value="more_than_one_cheapest_from_all">More than one cheapest from all</option>' +
|
146 |
'</select>';
|
147 |
form += '<div class="discount_product_option_more_cheapest_con hide">';
|
148 |
form += '<label>Item count<input type="text" name="discount_range['+count+'][discount_product_items]" class="form-control" value="" placeholder="ex. 1" /></label>';
|
155 |
form += '<select class="wc-product-search" multiple="multiple" style="width: 250px" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product…" data-action="woocommerce_json_search_products_and_variations"></select>'
|
156 |
}
|
157 |
form += '</div>';
|
158 |
+
form += '<div class="discount_product_percent_con">';
|
159 |
+
form += ' and <select class="selectpicker discount_product_discount_type" name="discount_range['+ count +'][discount_product_discount_type]"><option value="">100% percent</option><option value="limited_percent">Limited percent</option></select>';
|
160 |
+
form += '<label class="discount_product_percent_field"> Percent <input type="text" name="discount_range['+count+'][discount_product_percent]" class="form-control discount_product_percent_field" value="" placeholder="ex. 10" /></label>';
|
161 |
form += '</div>';
|
162 |
+
form += '</div>';
|
163 |
+
form += '</label> <label>Action<a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </label></div> </div>';
|
164 |
} else {
|
165 |
var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
|
166 |
'<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control price_discount_type" name="discount_range[' + count + '][discount_type]"> ' +
|
169 |
form += '<div class="price_discount_product_list_con hide"><select class="product_list selectpicker price_discount_product_list" multiple name="discount_range[' + count + '][discount_product][]">';
|
170 |
form += '<option>none</option>';
|
171 |
form += '</select></div>';
|
172 |
+
form += '</label> <label>Action<a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </label></div> </div>';
|
173 |
}
|
174 |
$('#discount_rule_list').append(form);
|
175 |
$('.product_list,.selectpicker').selectpicker('refresh');
|
396 |
$(document).on('change', '.price_discount_type', function () {
|
397 |
var discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_amount');
|
398 |
var price_discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_product_list_con');
|
399 |
+
var discount_product_percent_con = $(this).closest('.discount_rule_list').find('.discount_product_percent_con');
|
400 |
if($(this).val() == 'product_discount'){
|
401 |
discount_amount.hide();
|
402 |
price_discount_amount.removeClass('hide').show();
|
403 |
+
discount_product_percent_con.removeClass('hide').show();
|
404 |
$('.hide-for-product-discount').hide();
|
405 |
} else {
|
406 |
discount_amount.show();
|
407 |
price_discount_amount.hide();
|
408 |
+
discount_product_percent_con.hide();
|
409 |
$('.hide-for-product-discount').show();
|
410 |
}
|
411 |
});
|
415 |
$(document).on('change', 'select.discount_product_option', function () {
|
416 |
var discount_product = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_list_con');
|
417 |
var discount_product_more_cheapest = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_more_cheapest_con');
|
418 |
+
if($(this).val() == 'any_cheapest_from_all' || $(this).val() == 'more_than_one_cheapest_from_all'){
|
419 |
discount_product.addClass('hide');
|
420 |
} else {
|
421 |
discount_product.removeClass('hide');
|
422 |
}
|
423 |
+
if($(this).val() == 'more_than_one_cheapest' || $(this).val() == 'more_than_one_cheapest_from_all'){
|
424 |
discount_product_more_cheapest.removeClass('hide');
|
425 |
} else {
|
426 |
discount_product_more_cheapest.addClass('hide');
|
428 |
});
|
429 |
$('select.discount_product_option').trigger('change');
|
430 |
|
431 |
+
//on change discount_product_discount_type in product discount
|
432 |
+
$(document).on('change', 'select.discount_product_discount_type', function () {
|
433 |
+
var discount_product_percent_field = $(this).closest('.discount_product_percent_con').find('.discount_product_percent_field');
|
434 |
+
if($(this).val() == 'limited_percent'){
|
435 |
+
discount_product_percent_field.removeClass('hide');
|
436 |
+
} else {
|
437 |
+
discount_product_percent_field.addClass('hide');
|
438 |
+
}
|
439 |
+
});
|
440 |
+
$('select.discount_product_discount_type').trigger('change');
|
441 |
+
|
442 |
|
443 |
// Saving Cart Rule.
|
444 |
$('#saveCartRule').on('click', function (event) {
|
includes/pricing-rules.php
CHANGED
@@ -431,14 +431,14 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
431 |
$cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
|
432 |
|
433 |
//to handle buy one get one
|
434 |
-
$free_product_quantity_exists = $this->reduceCartItemQuantityIfFreeProductExistsAlready();
|
435 |
$this->matched_sets = array();
|
436 |
foreach ($cart_contents as $index => $item) {
|
437 |
$this->matchRules($index, $item, $product_page);
|
438 |
}
|
439 |
|
440 |
//to handle buy one get one
|
441 |
-
$this->applyDiscountForFreeProduct($free_product_quantity_exists);
|
442 |
|
443 |
$this->makeLog();
|
444 |
}
|
@@ -762,7 +762,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
762 |
|
763 |
case 'specific_products':
|
764 |
if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
|
765 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']));
|
766 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
767 |
}
|
768 |
break;
|
@@ -794,7 +794,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
794 |
}
|
795 |
}
|
796 |
if(!$alreadyExists){
|
797 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']));
|
798 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
799 |
}
|
800 |
}
|
@@ -803,7 +803,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
803 |
case 'all_products':
|
804 |
default:
|
805 |
if (!$this->isItemInProductList($rule['product_to_exclude'], $item)) {
|
806 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']));
|
807 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
808 |
}
|
809 |
|
@@ -963,10 +963,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
963 |
* Return the Adjustment amount.
|
964 |
*
|
965 |
* @param $quantity
|
966 |
-
* @param $
|
|
|
967 |
* @return array|bool
|
968 |
*/
|
969 |
-
public function getAdjustmentAmount($quantity, $discount_ranges)
|
970 |
{
|
971 |
$adjustment = array();
|
972 |
foreach($discount_ranges as $discount_range) {
|
@@ -986,27 +987,27 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
986 |
$productIds = isset($range->discount_product) ? $range->discount_product : array();
|
987 |
$productIds = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($productIds);
|
988 |
if($discount_product_option == 'any_cheapest_from_all'){
|
989 |
-
$productCheapest = $this->getCheapestProductFromCart($productIds, 1);
|
990 |
if(!empty($productCheapest)){
|
991 |
$adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
|
992 |
}
|
993 |
} else if($discount_product_option == 'any_cheapest'){
|
994 |
-
$productCheapest = $this->getCheapestProductFromCart($productIds);
|
995 |
if(!empty($productCheapest)){
|
996 |
$adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
|
997 |
}
|
998 |
-
} else if($discount_product_option == 'more_than_one_cheapest'){
|
999 |
$discount_product_items = (isset($range->discount_product_items) ? $range->discount_product_items : 1);
|
1000 |
if($discount_product_items < 1) $discount_product_items = 1;
|
1001 |
$discount_product_qty = (isset($range->discount_product_qty) ? $range->discount_product_qty : 1);
|
1002 |
if($discount_product_qty < 1) $discount_product_qty = 1;
|
1003 |
-
$productCheapest = $this->getMoreThanOneCheapestProductFromCart($productIds, $discount_product_qty, $discount_product_items);
|
1004 |
if(!empty($productCheapest)){
|
1005 |
$adjustment = $productCheapest ;
|
1006 |
}
|
1007 |
} else {
|
1008 |
//to handle product discount
|
1009 |
-
$free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
|
1010 |
if(!empty($productIds)){
|
1011 |
foreach ($productIds as $productId){
|
1012 |
if(isset($free_product[$productId])){
|
@@ -1016,7 +1017,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1016 |
$free_product[$productId]['rule_name'] = $range->title;
|
1017 |
}
|
1018 |
}
|
1019 |
-
WC()->session->set('woo_discount_rules_get_free_product', $free_product);
|
1020 |
}
|
1021 |
$adjustment[$type] = $productIds;
|
1022 |
}
|
@@ -1031,11 +1032,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1031 |
/**
|
1032 |
* Get More than one cheapest item
|
1033 |
* */
|
1034 |
-
public function getMoreThanOneCheapestProductFromCart($productIds, $discount_quantity = 1, $discount_item = 1){
|
|
|
1035 |
$adjustment = array();
|
1036 |
$adjustmentValues = array();
|
|
|
1037 |
for ($i = 1; $i <= $discount_item; $i++){
|
1038 |
-
$productCheapest = $this->getCheapestProductFromCart($productIds, 0, $discount_quantity);
|
1039 |
if(!empty($productCheapest)){
|
1040 |
$index = array_search($productCheapest['product'], $productIds);
|
1041 |
if ( $index !== false ) {
|
@@ -1053,10 +1056,22 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1053 |
return $adjustment;
|
1054 |
}
|
1055 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1056 |
/**
|
1057 |
* Get cheapest product
|
1058 |
* */
|
1059 |
-
public function getCheapestProductFromCart($products, $all = 0, $discount_quantity = 1){
|
1060 |
if(!$all){
|
1061 |
if(empty($products)) return array();
|
1062 |
}
|
@@ -1078,6 +1093,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1078 |
}
|
1079 |
}
|
1080 |
if($cheapestProductValue > 0){
|
|
|
|
|
|
|
|
|
|
|
1081 |
//discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
|
1082 |
if($discount_quantity > $quantity)
|
1083 |
$discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$quantity));
|
@@ -1580,6 +1600,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1580 |
$to_discount = isset($value->to_discount) ? $value->to_discount : 0;
|
1581 |
$product_discount = isset($value->discount_product) ? $value->discount_product : array();
|
1582 |
$discount_product_option = isset($value->discount_product_option) ? $value->discount_product_option : 'all';
|
|
|
|
|
1583 |
$discount_product_items = isset($value->discount_product_items) ? $value->discount_product_items : 1;
|
1584 |
$discount_product_qty = isset($value->discount_product_qty) ? $value->discount_product_qty : 1;
|
1585 |
$product_discount = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_discount);
|
@@ -1588,21 +1610,23 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1588 |
$condition = $min .' - ' . $max;
|
1589 |
if ($discount_type == 'product_discount') {
|
1590 |
$htmlProduct = '';
|
|
|
|
|
|
|
|
|
1591 |
if($discount_product_option == 'any_cheapest_from_all'){
|
1592 |
-
$htmlProduct .= esc_html__('
|
1593 |
} else {
|
1594 |
if($discount_product_option == 'any_cheapest'){
|
1595 |
-
$htmlProduct .= esc_html__('
|
1596 |
}
|
1597 |
-
if($discount_product_option == 'more_than_one_cheapest'){
|
1598 |
-
$htmlProduct .= esc_html__('Get ', 'woo-discount-rules');
|
1599 |
$htmlProduct .= $discount_product_qty;
|
1600 |
$htmlProduct .= esc_html__(' quantity of any ', 'woo-discount-rules');
|
1601 |
$htmlProduct .= $discount_product_items;
|
1602 |
$htmlProduct .= esc_html__(' cheapest item ', 'woo-discount-rules');
|
1603 |
-
|
1604 |
}
|
1605 |
-
if(count($product_discount)){
|
1606 |
foreach ($product_discount as $product_id){
|
1607 |
$product = FlycartWoocommerceProduct::wc_get_product($product_id);
|
1608 |
$htmlProduct .= "<a href='".FlycartWoocommerceProduct::get_permalink($product)."'>";
|
@@ -1612,7 +1636,6 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1612 |
}
|
1613 |
}
|
1614 |
}
|
1615 |
-
|
1616 |
$discount = trim($htmlProduct, '<br>');
|
1617 |
} else if ($discount_type == 'percentage_discount') {
|
1618 |
$discount = $to_discount.' %';
|
431 |
$cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
|
432 |
|
433 |
//to handle buy one get one
|
434 |
+
if(!$product_page) $free_product_quantity_exists = $this->reduceCartItemQuantityIfFreeProductExistsAlready();
|
435 |
$this->matched_sets = array();
|
436 |
foreach ($cart_contents as $index => $item) {
|
437 |
$this->matchRules($index, $item, $product_page);
|
438 |
}
|
439 |
|
440 |
//to handle buy one get one
|
441 |
+
if(!$product_page) $this->applyDiscountForFreeProduct($free_product_quantity_exists);
|
442 |
|
443 |
$this->makeLog();
|
444 |
}
|
762 |
|
763 |
case 'specific_products':
|
764 |
if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
|
765 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
766 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
767 |
}
|
768 |
break;
|
794 |
}
|
795 |
}
|
796 |
if(!$alreadyExists){
|
797 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
798 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
799 |
}
|
800 |
}
|
803 |
case 'all_products':
|
804 |
default:
|
805 |
if (!$this->isItemInProductList($rule['product_to_exclude'], $item)) {
|
806 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
807 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
808 |
}
|
809 |
|
963 |
* Return the Adjustment amount.
|
964 |
*
|
965 |
* @param $quantity
|
966 |
+
* @param $discount_ranges
|
967 |
+
* @param $product_page
|
968 |
* @return array|bool
|
969 |
*/
|
970 |
+
public function getAdjustmentAmount($quantity, $discount_ranges, $product_page)
|
971 |
{
|
972 |
$adjustment = array();
|
973 |
foreach($discount_ranges as $discount_range) {
|
987 |
$productIds = isset($range->discount_product) ? $range->discount_product : array();
|
988 |
$productIds = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($productIds);
|
989 |
if($discount_product_option == 'any_cheapest_from_all'){
|
990 |
+
$productCheapest = $this->getCheapestProductFromCart($productIds, 1, 1, $range);
|
991 |
if(!empty($productCheapest)){
|
992 |
$adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
|
993 |
}
|
994 |
} else if($discount_product_option == 'any_cheapest'){
|
995 |
+
$productCheapest = $this->getCheapestProductFromCart($productIds,0, 1, $range);
|
996 |
if(!empty($productCheapest)){
|
997 |
$adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
|
998 |
}
|
999 |
+
} else if($discount_product_option == 'more_than_one_cheapest' || $discount_product_option == 'more_than_one_cheapest_from_all'){
|
1000 |
$discount_product_items = (isset($range->discount_product_items) ? $range->discount_product_items : 1);
|
1001 |
if($discount_product_items < 1) $discount_product_items = 1;
|
1002 |
$discount_product_qty = (isset($range->discount_product_qty) ? $range->discount_product_qty : 1);
|
1003 |
if($discount_product_qty < 1) $discount_product_qty = 1;
|
1004 |
+
$productCheapest = $this->getMoreThanOneCheapestProductFromCart($productIds, $discount_product_qty, $discount_product_items, $range);
|
1005 |
if(!empty($productCheapest)){
|
1006 |
$adjustment = $productCheapest ;
|
1007 |
}
|
1008 |
} else {
|
1009 |
//to handle product discount
|
1010 |
+
if(!$product_page) $free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
|
1011 |
if(!empty($productIds)){
|
1012 |
foreach ($productIds as $productId){
|
1013 |
if(isset($free_product[$productId])){
|
1017 |
$free_product[$productId]['rule_name'] = $range->title;
|
1018 |
}
|
1019 |
}
|
1020 |
+
if(!$product_page) WC()->session->set('woo_discount_rules_get_free_product', $free_product);
|
1021 |
}
|
1022 |
$adjustment[$type] = $productIds;
|
1023 |
}
|
1032 |
/**
|
1033 |
* Get More than one cheapest item
|
1034 |
* */
|
1035 |
+
public function getMoreThanOneCheapestProductFromCart($productIds, $discount_quantity = 1, $discount_item = 1, $range){
|
1036 |
+
$discount_product_option = isset($range->discount_product_option) ? $range->discount_product_option : 'more_than_one_cheapest';
|
1037 |
$adjustment = array();
|
1038 |
$adjustmentValues = array();
|
1039 |
+
if($discount_product_option == "more_than_one_cheapest_from_all") $productIds = $this->getAllProductsFromCart();
|
1040 |
for ($i = 1; $i <= $discount_item; $i++){
|
1041 |
+
$productCheapest = $this->getCheapestProductFromCart($productIds, 0, $discount_quantity, $range);
|
1042 |
if(!empty($productCheapest)){
|
1043 |
$index = array_search($productCheapest['product'], $productIds);
|
1044 |
if ( $index !== false ) {
|
1056 |
return $adjustment;
|
1057 |
}
|
1058 |
|
1059 |
+
/**
|
1060 |
+
* Get all Products from Cart
|
1061 |
+
* */
|
1062 |
+
protected function getAllProductsFromCart(){
|
1063 |
+
$products = array();
|
1064 |
+
$cart = FlycartWoocommerceCart::get_cart();
|
1065 |
+
foreach ( $cart as $cart_item ) {
|
1066 |
+
$products[] = $cart_item['product_id'];
|
1067 |
+
}
|
1068 |
+
return $products;
|
1069 |
+
}
|
1070 |
+
|
1071 |
/**
|
1072 |
* Get cheapest product
|
1073 |
* */
|
1074 |
+
public function getCheapestProductFromCart($products, $all = 0, $discount_quantity = 1, $range){
|
1075 |
if(!$all){
|
1076 |
if(empty($products)) return array();
|
1077 |
}
|
1093 |
}
|
1094 |
}
|
1095 |
if($cheapestProductValue > 0){
|
1096 |
+
if(isset($range->discount_product_discount_type) && $range->discount_product_discount_type == "limited_percent"){
|
1097 |
+
if(isset($range->discount_product_percent) && $range->discount_product_percent > 0)
|
1098 |
+
$cheapestProductValue = $cheapestProductValue * ($range->discount_product_percent / 100);
|
1099 |
+
}
|
1100 |
+
|
1101 |
//discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
|
1102 |
if($discount_quantity > $quantity)
|
1103 |
$discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$quantity));
|
1600 |
$to_discount = isset($value->to_discount) ? $value->to_discount : 0;
|
1601 |
$product_discount = isset($value->discount_product) ? $value->discount_product : array();
|
1602 |
$discount_product_option = isset($value->discount_product_option) ? $value->discount_product_option : 'all';
|
1603 |
+
$discount_product_discount_type = isset($value->discount_product_discount_type) ? $value->discount_product_discount_type : '';
|
1604 |
+
$discount_product_percent = isset($value->discount_product_percent) ? $value->discount_product_percent : 0;
|
1605 |
$discount_product_items = isset($value->discount_product_items) ? $value->discount_product_items : 1;
|
1606 |
$discount_product_qty = isset($value->discount_product_qty) ? $value->discount_product_qty : 1;
|
1607 |
$product_discount = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_discount);
|
1610 |
$condition = $min .' - ' . $max;
|
1611 |
if ($discount_type == 'product_discount') {
|
1612 |
$htmlProduct = '';
|
1613 |
+
$htmlProduct .= esc_html__('Get ', 'woo-discount-rules');
|
1614 |
+
if($discount_product_discount_type == "limited_percent" && $discount_product_percent>0){
|
1615 |
+
$htmlProduct .= $discount_product_percent.esc_html__('% discount in ', 'woo-discount-rules');
|
1616 |
+
}
|
1617 |
if($discount_product_option == 'any_cheapest_from_all'){
|
1618 |
+
$htmlProduct .= esc_html__('any cheapest one from cart', 'woo-discount-rules');
|
1619 |
} else {
|
1620 |
if($discount_product_option == 'any_cheapest'){
|
1621 |
+
$htmlProduct .= esc_html__('any cheapest one of ', 'woo-discount-rules');
|
1622 |
}
|
1623 |
+
if($discount_product_option == 'more_than_one_cheapest' || $discount_product_option == 'more_than_one_cheapest_from_all'){
|
|
|
1624 |
$htmlProduct .= $discount_product_qty;
|
1625 |
$htmlProduct .= esc_html__(' quantity of any ', 'woo-discount-rules');
|
1626 |
$htmlProduct .= $discount_product_items;
|
1627 |
$htmlProduct .= esc_html__(' cheapest item ', 'woo-discount-rules');
|
|
|
1628 |
}
|
1629 |
+
if(count($product_discount) && $discount_product_option != 'more_than_one_cheapest_from_all'){
|
1630 |
foreach ($product_discount as $product_id){
|
1631 |
$product = FlycartWoocommerceProduct::wc_get_product($product_id);
|
1632 |
$htmlProduct .= "<a href='".FlycartWoocommerceProduct::get_permalink($product)."'>";
|
1636 |
}
|
1637 |
}
|
1638 |
}
|
|
|
1639 |
$discount = trim($htmlProduct, '<br>');
|
1640 |
} else if ($discount_type == 'percentage_discount') {
|
1641 |
$discount = $to_discount.' %';
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
|
|
4 |
Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -241,7 +241,10 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
-
= 1.4.
|
|
|
|
|
|
|
245 |
* Fix - apply wrong discount in cart while having product widget in cart page
|
246 |
|
247 |
= 1.4.42 - 06/02/18 =
|
4 |
Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.4.44
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
+
= 1.4.44 - 08/02/18 =
|
245 |
+
* Feature - Buy any or more products and get 10% discount in one or more cheapest (Pro)
|
246 |
+
|
247 |
+
= 1.4.43 - 07/02/18 =
|
248 |
* Fix - apply wrong discount in cart while having product widget in cart page
|
249 |
|
250 |
= 1.4.42 - 06/02/18 =
|
view/cart-rules.php
CHANGED
@@ -17,8 +17,17 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
17 |
<div class="row-fluid">
|
18 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
19 |
<div class="row">
|
20 |
-
<
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
<form method="post" action="?page=woo_discount_rules">
|
23 |
<div class="row">
|
24 |
<div class="col-md-4" id="add_new_rule_div">
|
@@ -45,76 +54,74 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
45 |
implemented.</code>
|
46 |
</div>
|
47 |
</div>
|
48 |
-
<
|
|
|
49 |
<div class="">
|
50 |
-
<
|
51 |
-
|
52 |
-
<
|
53 |
-
<
|
54 |
-
<
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
$status = isset($meta['status'][0]) ? $meta['status'][0] : 'disable';
|
71 |
-
$class = 'button button-secondary';
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
}
|
80 |
-
?>
|
81 |
-
|
82 |
-
<tr>
|
83 |
-
<td><?php echo(isset($meta['rule_name'][0]) ? $meta['rule_name'][0] : '-') ?></td>
|
84 |
-
<td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
|
85 |
-
<td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
|
86 |
-
<td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
|
87 |
-
<td>
|
88 |
-
<a class="button button-primary"
|
89 |
-
href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
|
90 |
-
Edit
|
91 |
-
</a>
|
92 |
-
<a class="<?php echo $class; ?> cart_manage_status"
|
93 |
-
id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
|
94 |
-
</a>
|
95 |
-
<a class="button button-secondary cart_delete_rule"
|
96 |
-
id="delete_<?php echo $rule->ID ?>">Delete
|
97 |
-
</a>
|
98 |
-
</td>
|
99 |
-
</tr>
|
100 |
-
<?php
|
101 |
-
$i++;
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
}
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
</
|
115 |
-
|
116 |
-
</
|
117 |
-
</
|
118 |
</div>
|
119 |
</div>
|
120 |
<hr>
|
17 |
<div class="row-fluid">
|
18 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
19 |
<div class="row">
|
20 |
+
<div class="row">
|
21 |
+
<div class="col-md-10">
|
22 |
+
<h4><h4>Cart Rules</h4></h4>
|
23 |
+
</div>
|
24 |
+
<div class="col-md-2">
|
25 |
+
<br/>
|
26 |
+
<a href="https://www.flycart.org/woocommerce-discount-rules-examples#cartdiscountexample" target="_blank" class="btn btn-info"><?php esc_html_e('View Examples', 'woo-discount-rules'); ?></a>
|
27 |
+
<a href="http://docs.flycart.org/woocommerce-discount-rules/cart-discount-rules" target="_blank" class="btn btn-info"><?php esc_html_e('Documentation', 'woo-discount-rules'); ?></a>
|
28 |
+
</div>
|
29 |
+
<hr>
|
30 |
+
</div>
|
31 |
<form method="post" action="?page=woo_discount_rules">
|
32 |
<div class="row">
|
33 |
<div class="col-md-4" id="add_new_rule_div">
|
54 |
implemented.</code>
|
55 |
</div>
|
56 |
</div>
|
57 |
+
<br>
|
58 |
+
<div class="">
|
59 |
<div class="">
|
60 |
+
<table class="wp-list-table widefat fixed striped posts">
|
61 |
+
<thead>
|
62 |
+
<tr>
|
63 |
+
<td>Name</td>
|
64 |
+
<td>Start Date</td>
|
65 |
+
<td>Expired On</td>
|
66 |
+
<td>Order</td>
|
67 |
+
<td>Action</td>
|
68 |
+
</tr>
|
69 |
+
</thead>
|
70 |
+
<tbody id="cart_rule">
|
71 |
+
<?php
|
72 |
+
$i = 1;
|
73 |
+
if (is_array($rule_list)) {
|
74 |
+
if (count($rule_list) > 0) {
|
75 |
+
foreach ($rule_list as $index => $rule) {
|
76 |
+
if (!$pro && $i > 3) continue;
|
77 |
+
$meta = $rule->meta;
|
78 |
+
$status = isset($meta['status'][0]) ? $meta['status'][0] : 'disable';
|
79 |
+
$class = 'button button-secondary';
|
|
|
|
|
80 |
|
81 |
+
if ($status == 'publish') {
|
82 |
+
$class = 'button button-primary';
|
83 |
+
$value = 'Disable';
|
84 |
+
} else {
|
85 |
+
$class = 'button button-secondary';
|
86 |
+
$value = 'Enable';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
+
?>
|
89 |
+
|
90 |
+
<tr>
|
91 |
+
<td><?php echo(isset($meta['rule_name'][0]) ? $meta['rule_name'][0] : '-') ?></td>
|
92 |
+
<td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
|
93 |
+
<td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
|
94 |
+
<td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
|
95 |
+
<td>
|
96 |
+
<a class="button button-primary"
|
97 |
+
href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
|
98 |
+
Edit
|
99 |
+
</a>
|
100 |
+
<a class="<?php echo $class; ?> cart_manage_status"
|
101 |
+
id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
|
102 |
+
</a>
|
103 |
+
<a class="button button-secondary cart_delete_rule"
|
104 |
+
id="delete_<?php echo $rule->ID ?>">Delete
|
105 |
+
</a>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
<?php
|
109 |
+
$i++;
|
110 |
}
|
111 |
}
|
112 |
+
}
|
113 |
+
?>
|
114 |
+
</tbody>
|
115 |
+
<tfoot>
|
116 |
+
<tr>
|
117 |
+
<td>Name</td>
|
118 |
+
<td>Start Date</td>
|
119 |
+
<td>Expired On</td>
|
120 |
+
<td>Order</td>
|
121 |
+
<td>Action</td>
|
122 |
+
</tr>
|
123 |
+
</tfoot>
|
124 |
+
</table>
|
125 |
</div>
|
126 |
</div>
|
127 |
<hr>
|
view/includes/footer.php
CHANGED
@@ -1,3 +1,10 @@
|
|
1 |
<?php if (!defined('ABSPATH')) exit; // Exit if accessed directly ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
</body>
|
3 |
</html>
|
1 |
<?php if (!defined('ABSPATH')) exit; // Exit if accessed directly ?>
|
2 |
+
<div class="row-fluid">
|
3 |
+
<div class="">
|
4 |
+
<div class="col-md-12">
|
5 |
+
<?php esc_html_e('Need help in setting up the rules?', 'woo-discount-rules'); ?> <a href="https://www.flycart.org/support" target="_blank" class=""><?php esc_html_e('Please contact our support team', 'woo-discount-rules'); ?></a>
|
6 |
+
</div>
|
7 |
+
</div>
|
8 |
+
</div>
|
9 |
</body>
|
10 |
</html>
|
view/pricing-rules.php
CHANGED
@@ -49,8 +49,15 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
49 |
<div class="row-fluid">
|
50 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
51 |
<div class="">
|
52 |
-
<div class="">
|
53 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
<hr>
|
55 |
</div>
|
56 |
<div class="">
|
@@ -76,76 +83,74 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
76 |
implemented.</code>
|
77 |
</div>
|
78 |
</div>
|
|
|
79 |
<div class="row">
|
80 |
<div class="">
|
81 |
-
<
|
82 |
-
|
83 |
-
<
|
84 |
-
<
|
85 |
-
<
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
102 |
$class = 'button button-secondary';
|
103 |
-
|
104 |
-
if ($status == 'publish') {
|
105 |
-
$class = 'button button-primary';
|
106 |
-
$value = 'Disable';
|
107 |
-
} else {
|
108 |
-
$class = 'button button-secondary';
|
109 |
-
$value = 'Enable';
|
110 |
-
}
|
111 |
-
?>
|
112 |
-
|
113 |
-
<tr>
|
114 |
-
<td><?php echo(isset($rule->rule_name) ? $rule->rule_name : '-') ?></td>
|
115 |
-
<td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
|
116 |
-
<td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
|
117 |
-
<td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
|
118 |
-
<td>
|
119 |
-
<a class="button button-primary"
|
120 |
-
href="?page=woo_discount_rules&view=<?php echo $rule->ID ?>">
|
121 |
-
Edit
|
122 |
-
</a>
|
123 |
-
<a class="<?php echo $class; ?> manage_status"
|
124 |
-
id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
|
125 |
-
</a>
|
126 |
-
<a class="button button-secondary delete_rule"
|
127 |
-
id="delete_<?php echo $rule->ID ?>">Delete
|
128 |
-
</a>
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
<?php
|
132 |
-
$i++;
|
133 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
}
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
</
|
146 |
-
|
147 |
-
</
|
148 |
-
</
|
149 |
</div>
|
150 |
</div>
|
151 |
<hr>
|
49 |
<div class="row-fluid">
|
50 |
<div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
|
51 |
<div class="">
|
52 |
+
<div class="row">
|
53 |
+
<div class="col-md-10">
|
54 |
+
<h4>Price Rules</h4>
|
55 |
+
</div>
|
56 |
+
<div class="col-md-2">
|
57 |
+
<br/>
|
58 |
+
<a href="https://www.flycart.org/woocommerce-discount-rules-examples#pricediscountexample" target="_blank" class="btn btn-info"><?php esc_html_e('View Examples', 'woo-discount-rules'); ?></a>
|
59 |
+
<a href="http://docs.flycart.org/woocommerce-discount-rules/price-discount-rules" target="_blank" class="btn btn-info"><?php esc_html_e('Documentation', 'woo-discount-rules'); ?></a>
|
60 |
+
</div>
|
61 |
<hr>
|
62 |
</div>
|
63 |
<div class="">
|
83 |
implemented.</code>
|
84 |
</div>
|
85 |
</div>
|
86 |
+
<br>
|
87 |
<div class="row">
|
88 |
<div class="">
|
89 |
+
<table class="wp-list-table widefat fixed striped posts">
|
90 |
+
<thead>
|
91 |
+
<tr>
|
92 |
+
<td>Name</td>
|
93 |
+
<td>Start Date</td>
|
94 |
+
<td>Expired On</td>
|
95 |
+
<td>Order</td>
|
96 |
+
<td>Action</td>
|
97 |
+
</tr>
|
98 |
+
</thead>
|
99 |
+
<tbody id="pricing_rule">
|
100 |
+
<?php
|
101 |
+
$i = 1;
|
102 |
+
if (is_array($rule_list)) {
|
103 |
+
if (count($rule_list) > 0) {
|
104 |
+
foreach ($rule_list as $index => $rule) {
|
105 |
+
if (!$pro && $i > 3) continue;
|
106 |
+
$meta = $rule->meta;
|
107 |
+
$status = isset($meta['status'][0]) ? $meta['status'][0] : 'disable';
|
108 |
+
$class = 'button button-secondary';
|
109 |
+
|
110 |
+
if ($status == 'publish') {
|
111 |
+
$class = 'button button-primary';
|
112 |
+
$value = 'Disable';
|
113 |
+
} else {
|
114 |
$class = 'button button-secondary';
|
115 |
+
$value = 'Enable';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
+
?>
|
118 |
+
|
119 |
+
<tr>
|
120 |
+
<td><?php echo(isset($rule->rule_name) ? $rule->rule_name : '-') ?></td>
|
121 |
+
<td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
|
122 |
+
<td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
|
123 |
+
<td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
|
124 |
+
<td>
|
125 |
+
<a class="button button-primary"
|
126 |
+
href="?page=woo_discount_rules&view=<?php echo $rule->ID ?>">
|
127 |
+
Edit
|
128 |
+
</a>
|
129 |
+
<a class="<?php echo $class; ?> manage_status"
|
130 |
+
id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
|
131 |
+
</a>
|
132 |
+
<a class="button button-secondary delete_rule"
|
133 |
+
id="delete_<?php echo $rule->ID ?>">Delete
|
134 |
+
</a>
|
135 |
+
</td>
|
136 |
+
</tr>
|
137 |
+
<?php
|
138 |
+
$i++;
|
139 |
}
|
140 |
}
|
141 |
+
}
|
142 |
+
?>
|
143 |
+
</tbody>
|
144 |
+
<tfoot>
|
145 |
+
<tr>
|
146 |
+
<td>Name</td>
|
147 |
+
<td>Start Date</td>
|
148 |
+
<td>Expired On</td>
|
149 |
+
<td>Order</td>
|
150 |
+
<td>Action</td>
|
151 |
+
</tr>
|
152 |
+
</tfoot>
|
153 |
+
</table>
|
154 |
</div>
|
155 |
</div>
|
156 |
<hr>
|
view/template/sidebar.php
CHANGED
@@ -2,6 +2,10 @@
|
|
2 |
<div class="col-md-3">
|
3 |
<div class="container-fluid">
|
4 |
<div class="row-fluid">
|
|
|
|
|
|
|
|
|
5 |
<div class="col-md-12">
|
6 |
<div id="" align="right">
|
7 |
<div class="woo-side-button" class="hide-on-click">
|
2 |
<div class="col-md-3">
|
3 |
<div class="container-fluid">
|
4 |
<div class="row-fluid">
|
5 |
+
<div class="col-md-12">
|
6 |
+
<br>
|
7 |
+
<a href="https://www.flycart.org/products/wordpress/woocommerce-discount-rules?utm_source=wpwoodiscountrules&utm_medium=plugin&utm_campaign=inline&utm_content=woo-discount-rules" target="_blank" class="btn btn-success"><?php esc_html_e('Looking for more features? Upgrade to PRO', 'woo-discount-rules'); ?></a>
|
8 |
+
</div>
|
9 |
<div class="col-md-12">
|
10 |
<div id="" align="right">
|
11 |
<div class="woo-side-button" class="hide-on-click">
|
view/view-pricing-rules.php
CHANGED
@@ -421,6 +421,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
421 |
<option value="any_cheapest"<?php echo ($discount_product_option == 'any_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from selected', 'woo-discount-rules') ?></option>
|
422 |
<option value="any_cheapest_from_all"<?php echo ($discount_product_option == 'any_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from all products', 'woo-discount-rules') ?></option>
|
423 |
<option value="more_than_one_cheapest"<?php echo ($discount_product_option == 'more_than_one_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from selected', 'woo-discount-rules') ?></option>
|
|
|
424 |
</select>
|
425 |
<div class="discount_product_option_more_cheapest_con hide">
|
426 |
<label>Item count
|
@@ -443,6 +444,23 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
443 |
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($products_list, "discount_range[".$fieldIndex."][discount_product]");
|
444 |
?>
|
445 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
</div>
|
447 |
</label>
|
448 |
|
421 |
<option value="any_cheapest"<?php echo ($discount_product_option == 'any_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from selected', 'woo-discount-rules') ?></option>
|
422 |
<option value="any_cheapest_from_all"<?php echo ($discount_product_option == 'any_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from all products', 'woo-discount-rules') ?></option>
|
423 |
<option value="more_than_one_cheapest"<?php echo ($discount_product_option == 'more_than_one_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from selected', 'woo-discount-rules') ?></option>
|
424 |
+
<option value="more_than_one_cheapest_from_all"<?php echo ($discount_product_option == 'more_than_one_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from all', 'woo-discount-rules') ?></option>
|
425 |
</select>
|
426 |
<div class="discount_product_option_more_cheapest_con hide">
|
427 |
<label>Item count
|
444 |
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($products_list, "discount_range[".$fieldIndex."][discount_product]");
|
445 |
?>
|
446 |
</div>
|
447 |
+
<div class="discount_product_percent_con hide">
|
448 |
+
<?php
|
449 |
+
$discount_product_discount_type = (isset($discount->discount_product_discount_type) ? $discount->discount_product_discount_type : '');
|
450 |
+
?> and
|
451 |
+
<select class="selectpicker discount_product_discount_type" name="discount_range[<?php echo $fieldIndex; ?>][discount_product_discount_type]">
|
452 |
+
<option value=""<?php echo ($discount_product_discount_type == '')? ' selected="selected"': '' ?>><?php esc_html_e('100% percent', 'woo-discount-rules') ?></option>
|
453 |
+
<option value="limited_percent"<?php echo ($discount_product_discount_type == 'limited_percent')? ' selected="selected"': '' ?>><?php esc_html_e('Limited percent', 'woo-discount-rules') ?></option>
|
454 |
+
</select>
|
455 |
+
<label class="discount_product_percent_field">Percent
|
456 |
+
<input type="text"
|
457 |
+
name="discount_range[<?php echo $fieldIndex; ?>][discount_product_percent]"
|
458 |
+
class="form-control discount_product_percent_field"
|
459 |
+
value="<?php echo(isset($discount->discount_product_percent) ? $discount->discount_product_percent : ''); ?>"
|
460 |
+
placeholder="ex. 10" />
|
461 |
+
</label>
|
462 |
+
as discount
|
463 |
+
</div>
|
464 |
</div>
|
465 |
</label>
|
466 |
|
woo-discount-rules.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 1.4.
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Requires at least: 4.6.1
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 1.4.44
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Requires at least: 4.6.1
|