Version Description
- 23/04/18 =
- Fix - Category subtotal in cart rule while have multiple categories to a product.
- Fix - Discount lowest to highest price in product page for variants, while having large number of variants
- Fix - Wrong discount price with tax in product page
- Feature - Skip/Apply first n number of products in product dependent rules(Pro)
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.5.10 |
Comparing to | |
See all releases |
Code changes from version 1.5.9 to 1.5.10
- assets/js/app.js +11 -0
- includes/cart-rules.php +11 -36
- includes/pricing-rules.php +67 -13
- loader.php +1 -0
- readme.txt +7 -1
- view/view-pricing-rules.php +11 -1
- woo-discount-rules.php +1 -1
assets/js/app.js
CHANGED
@@ -622,6 +622,17 @@ function validateFields(){
|
|
622 |
}
|
623 |
});
|
624 |
$('#product_based_condition_quantity_rule').trigger('change');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
//--------------------------------------------------------------------------------------------------------------
|
626 |
//-----------------------------------------------SETTINGS-------------------------------------------------------
|
627 |
//--------------------------------------------------------------------------------------------------------------
|
622 |
}
|
623 |
});
|
624 |
$('#product_based_condition_quantity_rule').trigger('change');
|
625 |
+
|
626 |
+
// product_based_condition_product_to_apply_count_option
|
627 |
+
$('#product_based_condition_product_to_apply_count_option').on('change', function () {
|
628 |
+
var value = $(this).val();
|
629 |
+
if(value == 'all'){
|
630 |
+
$('#product_based_condition_product_to_apply_count').css({"display": "none"})
|
631 |
+
} else {
|
632 |
+
$('#product_based_condition_product_to_apply_count').css({"display": "inline-block"})
|
633 |
+
}
|
634 |
+
});
|
635 |
+
$('#product_based_condition_product_to_apply_count_option').trigger('change');
|
636 |
//--------------------------------------------------------------------------------------------------------------
|
637 |
//-----------------------------------------------SETTINGS-------------------------------------------------------
|
638 |
//--------------------------------------------------------------------------------------------------------------
|
includes/cart-rules.php
CHANGED
@@ -1039,53 +1039,28 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
|
|
1039 |
protected function validateCartItemsInSelectedCategory($index, $rule, $rules){
|
1040 |
$ruleSuccess = 0;
|
1041 |
global $woocommerce;
|
1042 |
-
$
|
1043 |
if(count($woocommerce->cart->cart_contents)){
|
1044 |
foreach ($woocommerce->cart->cart_contents as $key => $cartItem) {
|
1045 |
$terms = get_the_terms( $cartItem['product_id'], 'product_cat' );
|
|
|
1046 |
if($terms){
|
1047 |
foreach ($terms as $term) {
|
1048 |
-
$
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
$sub_total = $product_cat_id[$term->term_id]->sub_total;
|
1053 |
-
$quantity = $product_cat_id[$term->term_id]->quantity;
|
1054 |
-
$item_count = $product_cat_id[$term->term_id]->item_count;
|
1055 |
}
|
1056 |
-
$productDetailObject = new stdClass();
|
1057 |
-
$productDetailObject->cat_id = $term->term_id;
|
1058 |
-
$productDetailObject->product_id = trim($product_id.$cartItem['product_id'], ',');
|
1059 |
-
$productDetailObject->sub_total = $sub_total+$cartItem['line_subtotal'];//+$cartItem['line_subtotal_tax'];
|
1060 |
-
$productDetailObject->quantity = $quantity+$cartItem['quantity'];
|
1061 |
-
$productDetailObject->item_count = $item_count+1;
|
1062 |
-
$product_cat_id[$term->term_id] = $productDetailObject;
|
1063 |
}
|
1064 |
}
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
$product_id = $cat_id = '';
|
1070 |
-
$sub_total = $quantity = $item_count = 0;
|
1071 |
-
$existingProductId = array();
|
1072 |
-
foreach ($rule as $catid){
|
1073 |
-
if(in_array($catid, $category_ids)){
|
1074 |
-
if(isset($product_cat_id[$catid])){
|
1075 |
-
$categoryFound = 1;
|
1076 |
-
if(isset($existingProductId[$product_cat_id[$catid]->product_id])){
|
1077 |
-
$existingProductId[$product_cat_id[$catid]->product_id]['cat_ids'][] = $product_cat_id[$catid]->cat_id;
|
1078 |
-
} else {
|
1079 |
-
$existingProductId[$product_cat_id[$catid]->product_id]['cat_ids'][] = $product_cat_id[$catid]->cat_id;
|
1080 |
-
$cat_id = trim($cat_id.','.$product_cat_id[$catid]->cat_id, ',');
|
1081 |
-
$product_id = trim($product_id.','.$product_cat_id[$catid]->product_id, ',');
|
1082 |
-
$sub_total = $sub_total+$product_cat_id[$catid]->sub_total;
|
1083 |
-
$quantity = $quantity+$product_cat_id[$catid]->quantity;
|
1084 |
-
$item_count = $item_count+$product_cat_id[$catid]->item_count;
|
1085 |
-
}
|
1086 |
}
|
1087 |
}
|
1088 |
}
|
|
|
1089 |
if($categoryFound){
|
1090 |
$ruleSuccess = 1;
|
1091 |
foreach ($rules as $rule_type => $rule_values){
|
1039 |
protected function validateCartItemsInSelectedCategory($index, $rule, $rules){
|
1040 |
$ruleSuccess = 0;
|
1041 |
global $woocommerce;
|
1042 |
+
$categoryFound = $sub_total = $quantity = $item_count = 0;
|
1043 |
if(count($woocommerce->cart->cart_contents)){
|
1044 |
foreach ($woocommerce->cart->cart_contents as $key => $cartItem) {
|
1045 |
$terms = get_the_terms( $cartItem['product_id'], 'product_cat' );
|
1046 |
+
$categoryMatches = 0;
|
1047 |
if($terms){
|
1048 |
foreach ($terms as $term) {
|
1049 |
+
if(in_array($term->term_id, $rule)){
|
1050 |
+
$categoryMatches = 1;
|
1051 |
+
$categoryFound = 1;
|
1052 |
+
break;
|
|
|
|
|
|
|
1053 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1054 |
}
|
1055 |
}
|
1056 |
+
if($categoryMatches){
|
1057 |
+
$sub_total += $cartItem['line_subtotal'];//+$cartItem['line_subtotal_tax'];
|
1058 |
+
$quantity += $cartItem['quantity'];
|
1059 |
+
$item_count++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1060 |
}
|
1061 |
}
|
1062 |
}
|
1063 |
+
|
1064 |
if($categoryFound){
|
1065 |
$ruleSuccess = 1;
|
1066 |
foreach ($rules as $rule_type => $rule_values){
|
includes/pricing-rules.php
CHANGED
@@ -1017,10 +1017,16 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1017 |
} else if(isset($rule['method']) && $rule['method'] == 'product_based'){
|
1018 |
$checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
|
1019 |
if(!empty($checkRuleMatches)){
|
|
|
|
|
1020 |
foreach ($checkRuleMatches['apply_to']['products'] as $key => $productId) {
|
1021 |
if($product_page && $productId == $index){
|
1022 |
$additionalKeys = array('apply_from' => $item['product_id']);
|
1023 |
-
|
|
|
|
|
|
|
|
|
1024 |
$this->matched_sets[$index][] = $applied_rules_new;
|
1025 |
} else {
|
1026 |
$cart = FlycartWoocommerceCart::get_cart();
|
@@ -1028,7 +1034,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1028 |
$_product = $values['data'];
|
1029 |
if (FlycartWoocommerceProduct::get_id($_product) == $productId){
|
1030 |
$additionalKeys = array('apply_from' => $item['product_id']);
|
1031 |
-
|
|
|
|
|
|
|
|
|
1032 |
$alreadyExists = 0;
|
1033 |
if(!empty($this->matched_sets[$cart_item_key])){
|
1034 |
foreach($this->matched_sets[$cart_item_key] as $machedRules){
|
@@ -1777,6 +1787,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1777 |
$product_to_buy = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_buy);
|
1778 |
$product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
1779 |
$product_to_apply = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_apply);
|
|
|
|
|
1780 |
$condition = esc_html__('Buy', 'woo-discount-rules');
|
1781 |
|
1782 |
switch ($product_quantity_rule) {
|
@@ -1820,6 +1832,15 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1820 |
$condition .= ' '.trim($htmlProduct, ', ').' ';
|
1821 |
}
|
1822 |
$condition .= esc_html__(' and get discount in ', 'woo-discount-rules');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1823 |
if(count($product_to_apply)){
|
1824 |
$htmlProduct = '';
|
1825 |
foreach ($product_to_apply as $product_id){
|
@@ -2039,7 +2060,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2039 |
* @param string $by
|
2040 |
* @return bool|float|int
|
2041 |
*/
|
2042 |
-
public function getAmount($sets, $price, $by = 'all')
|
2043 |
{
|
2044 |
$discount = 0;
|
2045 |
$overall_discount = 0;
|
@@ -2050,7 +2071,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2050 |
|
2051 |
// For the biggest price, it compares the current product's price.
|
2052 |
if ($by == 'biggest') {
|
2053 |
-
$discount = $this->getBiggestDiscount($sets, $price);
|
2054 |
return $discount;
|
2055 |
}
|
2056 |
|
@@ -2061,6 +2082,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2061 |
$discount = ($price / 100) * $set['amount']['percentage_discount'];
|
2062 |
} else if (isset($set['amount']['price_discount'])) {
|
2063 |
$discount = $set['amount']['price_discount'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2064 |
}
|
2065 |
return $discount;
|
2066 |
} else {
|
@@ -2071,6 +2099,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2071 |
$overall_discount = $overall_discount + $discount;
|
2072 |
} else if (isset($set['amount']['price_discount'])) {
|
2073 |
$discount = $set['amount']['price_discount'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2074 |
// Append all Discounts.
|
2075 |
$overall_discount = $overall_discount + $discount;
|
2076 |
}
|
@@ -2086,11 +2121,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2086 |
* @param $price
|
2087 |
* @return float|int
|
2088 |
*/
|
2089 |
-
public function getBiggestDiscount($discount_list, $price)
|
2090 |
{
|
2091 |
-
$big = 0;
|
2092 |
-
// $amount = $price;
|
2093 |
-
$amount = 0;
|
2094 |
foreach ($discount_list as $id => $discount_item) {
|
2095 |
$amount_type = (isset($discount_item['amount']['percentage_discount']) ? 'percentage_discount' : 'price_discount');
|
2096 |
if ($amount_type == 'percentage_discount') {
|
@@ -2100,6 +2133,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2100 |
} else {
|
2101 |
if (isset($discount_item['amount']['price_discount'])) {
|
2102 |
$amount = $discount_item['amount']['price_discount'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2103 |
}
|
2104 |
}
|
2105 |
|
@@ -2143,7 +2183,6 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2143 |
// Actually adjust price in cart
|
2144 |
// $woocommerce->cart->cart_contents[$item]['data']->price = $amount;
|
2145 |
FlycartWoocommerceProduct::set_price($product, $amount);
|
2146 |
-
|
2147 |
}
|
2148 |
|
2149 |
/**
|
@@ -2233,13 +2272,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2233 |
}
|
2234 |
}
|
2235 |
$maxProductId = 0;
|
|
|
2236 |
if ( ! empty( $child_prices ) ) {
|
2237 |
$min_price = min( $child_prices );
|
2238 |
$max_price = max( $child_prices );
|
2239 |
if($min_price != $max_price){
|
2240 |
$maxProductIds = array_keys($child_prices, $max_price);
|
|
|
2241 |
if(isset($maxProductIds[0]))
|
2242 |
$maxProductId = $maxProductIds[0];
|
|
|
|
|
2243 |
}
|
2244 |
}
|
2245 |
|
@@ -2251,7 +2294,18 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2251 |
} else {
|
2252 |
$greatestDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($maxProduct));
|
2253 |
}
|
2254 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2255 |
}
|
2256 |
|
2257 |
return $price_to_display;
|
@@ -2340,14 +2394,14 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2340 |
$discount = 0;
|
2341 |
if ($type == 'first') {
|
2342 |
// For Apply the First Rule.
|
2343 |
-
$discount = $this->getAmount($adjustment_set, $price, 'first');
|
2344 |
|
2345 |
} else if ($type == 'biggest') {
|
2346 |
// For Apply the Biggest Discount.
|
2347 |
-
$discount = $this->getAmount($adjustment_set, $price, 'biggest');
|
2348 |
} else {
|
2349 |
// For Apply All Rules.
|
2350 |
-
$discount = $this->getAmount($adjustment_set, $price);
|
2351 |
}
|
2352 |
if($discount > 0){
|
2353 |
$amount = $price - $discount;
|
1017 |
} else if(isset($rule['method']) && $rule['method'] == 'product_based'){
|
1018 |
$checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
|
1019 |
if(!empty($checkRuleMatches)){
|
1020 |
+
if(class_exists('FlycartWooDiscountRulesPriceProductDependent'))
|
1021 |
+
$discountInEachProducts = FlycartWooDiscountRulesPriceProductDependent::getDiscountInEachProducts($rule, $checkRuleMatches, $product_page, $index);
|
1022 |
foreach ($checkRuleMatches['apply_to']['products'] as $key => $productId) {
|
1023 |
if($product_page && $productId == $index){
|
1024 |
$additionalKeys = array('apply_from' => $item['product_id']);
|
1025 |
+
if(isset($discountInEachProducts[$productId]))
|
1026 |
+
$discount_amount = $discountInEachProducts[$productId];
|
1027 |
+
else
|
1028 |
+
$discount_amount = $checkRuleMatches['amount'];
|
1029 |
+
$applied_rules_new = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $productId, $id, $additionalKeys);
|
1030 |
$this->matched_sets[$index][] = $applied_rules_new;
|
1031 |
} else {
|
1032 |
$cart = FlycartWoocommerceCart::get_cart();
|
1034 |
$_product = $values['data'];
|
1035 |
if (FlycartWoocommerceProduct::get_id($_product) == $productId){
|
1036 |
$additionalKeys = array('apply_from' => $item['product_id']);
|
1037 |
+
if(isset($discountInEachProducts[$productId]))
|
1038 |
+
$discount_amount = $discountInEachProducts[$productId];
|
1039 |
+
else
|
1040 |
+
$discount_amount = $checkRuleMatches['amount'];
|
1041 |
+
$applied_rules_new = $this->formatRulesToApply($discount_amount, $rule['name'], $cart_item_key, $productId, $id, $additionalKeys);
|
1042 |
$alreadyExists = 0;
|
1043 |
if(!empty($this->matched_sets[$cart_item_key])){
|
1044 |
foreach($this->matched_sets[$cart_item_key] as $machedRules){
|
1787 |
$product_to_buy = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_buy);
|
1788 |
$product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
1789 |
$product_to_apply = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_apply);
|
1790 |
+
$product_to_apply_count_option = isset($product_based_conditions['product_to_apply_count_option']) ? $product_based_conditions['product_to_apply_count_option'] : 'all';
|
1791 |
+
$product_to_apply_count = isset($product_based_conditions['product_to_apply_count']) ? $product_based_conditions['product_to_apply_count'] : 0;
|
1792 |
$condition = esc_html__('Buy', 'woo-discount-rules');
|
1793 |
|
1794 |
switch ($product_quantity_rule) {
|
1832 |
$condition .= ' '.trim($htmlProduct, ', ').' ';
|
1833 |
}
|
1834 |
$condition .= esc_html__(' and get discount in ', 'woo-discount-rules');
|
1835 |
+
if($product_to_apply_count_option == 'apply_first'){
|
1836 |
+
$condition .= esc_html__(' first ', 'woo-discount-rules');
|
1837 |
+
$condition .= $product_to_apply_count;
|
1838 |
+
$condition .= esc_html__(' quantity of product(s) - ', 'woo-discount-rules');
|
1839 |
+
} else if($product_to_apply_count_option == 'skip_first'){
|
1840 |
+
$condition .= esc_html__(' after first ', 'woo-discount-rules');
|
1841 |
+
$condition .= $product_to_apply_count;
|
1842 |
+
$condition .= esc_html__(' quantity of product(s) - ', 'woo-discount-rules');
|
1843 |
+
}
|
1844 |
if(count($product_to_apply)){
|
1845 |
$htmlProduct = '';
|
1846 |
foreach ($product_to_apply as $product_id){
|
2060 |
* @param string $by
|
2061 |
* @return bool|float|int
|
2062 |
*/
|
2063 |
+
public function getAmount($sets, $price, $by = 'all', $product_page = 0, $product = array())
|
2064 |
{
|
2065 |
$discount = 0;
|
2066 |
$overall_discount = 0;
|
2071 |
|
2072 |
// For the biggest price, it compares the current product's price.
|
2073 |
if ($by == 'biggest') {
|
2074 |
+
$discount = $this->getBiggestDiscount($sets, $price, $product_page, $product);
|
2075 |
return $discount;
|
2076 |
}
|
2077 |
|
2082 |
$discount = ($price / 100) * $set['amount']['percentage_discount'];
|
2083 |
} else if (isset($set['amount']['price_discount'])) {
|
2084 |
$discount = $set['amount']['price_discount'];
|
2085 |
+
if($product_page){
|
2086 |
+
if(get_option('woocommerce_prices_include_tax', 'no') == 'no'){
|
2087 |
+
if(get_option('woocommerce_tax_display_shop', 'incl') == 'incl'){
|
2088 |
+
$discount = FlycartWoocommerceProduct::get_price_including_tax($product, 1, $discount);
|
2089 |
+
}
|
2090 |
+
}
|
2091 |
+
}
|
2092 |
}
|
2093 |
return $discount;
|
2094 |
} else {
|
2099 |
$overall_discount = $overall_discount + $discount;
|
2100 |
} else if (isset($set['amount']['price_discount'])) {
|
2101 |
$discount = $set['amount']['price_discount'];
|
2102 |
+
if($product_page){
|
2103 |
+
if(get_option('woocommerce_prices_include_tax', 'no') == 'no'){
|
2104 |
+
if(get_option('woocommerce_tax_display_shop', 'incl') == 'incl'){
|
2105 |
+
$discount = FlycartWoocommerceProduct::get_price_including_tax($product, 1, $discount);
|
2106 |
+
}
|
2107 |
+
}
|
2108 |
+
}
|
2109 |
// Append all Discounts.
|
2110 |
$overall_discount = $overall_discount + $discount;
|
2111 |
}
|
2121 |
* @param $price
|
2122 |
* @return float|int
|
2123 |
*/
|
2124 |
+
public function getBiggestDiscount($discount_list, $price, $product_page = 0, $product = array())
|
2125 |
{
|
2126 |
+
$big = $amount = 0;
|
|
|
|
|
2127 |
foreach ($discount_list as $id => $discount_item) {
|
2128 |
$amount_type = (isset($discount_item['amount']['percentage_discount']) ? 'percentage_discount' : 'price_discount');
|
2129 |
if ($amount_type == 'percentage_discount') {
|
2133 |
} else {
|
2134 |
if (isset($discount_item['amount']['price_discount'])) {
|
2135 |
$amount = $discount_item['amount']['price_discount'];
|
2136 |
+
if($product_page){
|
2137 |
+
if(get_option('woocommerce_prices_include_tax', 'no') == 'no'){
|
2138 |
+
if(get_option('woocommerce_tax_display_shop', 'incl') == 'incl'){
|
2139 |
+
$amount = FlycartWoocommerceProduct::get_price_including_tax($product, 1, $amount);
|
2140 |
+
}
|
2141 |
+
}
|
2142 |
+
}
|
2143 |
}
|
2144 |
}
|
2145 |
|
2183 |
// Actually adjust price in cart
|
2184 |
// $woocommerce->cart->cart_contents[$item]['data']->price = $amount;
|
2185 |
FlycartWoocommerceProduct::set_price($product, $amount);
|
|
|
2186 |
}
|
2187 |
|
2188 |
/**
|
2272 |
}
|
2273 |
}
|
2274 |
$maxProductId = 0;
|
2275 |
+
$minProductId = 0;
|
2276 |
if ( ! empty( $child_prices ) ) {
|
2277 |
$min_price = min( $child_prices );
|
2278 |
$max_price = max( $child_prices );
|
2279 |
if($min_price != $max_price){
|
2280 |
$maxProductIds = array_keys($child_prices, $max_price);
|
2281 |
+
$minProductIds = array_keys($child_prices, $min_price);
|
2282 |
if(isset($maxProductIds[0]))
|
2283 |
$maxProductId = $maxProductIds[0];
|
2284 |
+
if(isset($minProductIds[0]))
|
2285 |
+
$minProductId = $minProductIds[0];
|
2286 |
}
|
2287 |
}
|
2288 |
|
2294 |
} else {
|
2295 |
$greatestDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($maxProduct));
|
2296 |
}
|
2297 |
+
if($minProductId){
|
2298 |
+
$minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
|
2299 |
+
$leastDiscountPrice = $this->getDiscountPriceForTheProduct($minProduct);
|
2300 |
+
if($leastDiscountPrice > 0){
|
2301 |
+
$leastDiscountPrice = FlycartWoocommerceProduct::wc_price($leastDiscountPrice);
|
2302 |
+
} else {
|
2303 |
+
$leastDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($minProduct));
|
2304 |
+
}
|
2305 |
+
$price_to_display = $leastDiscountPrice.' - '.$greatestDiscountPrice;
|
2306 |
+
} else {
|
2307 |
+
$price_to_display .= ' - '.$greatestDiscountPrice;
|
2308 |
+
}
|
2309 |
}
|
2310 |
|
2311 |
return $price_to_display;
|
2394 |
$discount = 0;
|
2395 |
if ($type == 'first') {
|
2396 |
// For Apply the First Rule.
|
2397 |
+
$discount = $this->getAmount($adjustment_set, $price, 'first', 1, $cart_item);
|
2398 |
|
2399 |
} else if ($type == 'biggest') {
|
2400 |
// For Apply the Biggest Discount.
|
2401 |
+
$discount = $this->getAmount($adjustment_set, $price, 'biggest', 1, $cart_item);
|
2402 |
} else {
|
2403 |
// For Apply All Rules.
|
2404 |
+
$discount = $this->getAmount($adjustment_set, $price, 'all', 1, $cart_item);
|
2405 |
}
|
2406 |
if($discount > 0){
|
2407 |
$amount = $price - $discount;
|
loader.php
CHANGED
@@ -210,5 +210,6 @@ if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
|
210 |
$purchase_helper = new FlycartWooDiscountRulesPurchase();
|
211 |
if($purchase_helper->isPro()){
|
212 |
include_once('includes/advanced/free_shipping_method.php');
|
|
|
213 |
}
|
214 |
}
|
210 |
$purchase_helper = new FlycartWooDiscountRulesPurchase();
|
211 |
if($purchase_helper->isPro()){
|
212 |
include_once('includes/advanced/free_shipping_method.php');
|
213 |
+
include_once('includes/advanced/pricing-productdependent.php');
|
214 |
}
|
215 |
}
|
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.5.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -243,6 +243,12 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
243 |
|
244 |
== Changelog ==
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
= 1.5.9 - 18/04/18 =
|
247 |
* Feature - Free shipping option in cart rule(Pro)
|
248 |
|
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.5.10
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
243 |
|
244 |
== Changelog ==
|
245 |
|
246 |
+
= 1.5.10 - 23/04/18 =
|
247 |
+
* Fix - Category subtotal in cart rule while have multiple categories to a product.
|
248 |
+
* Fix - Discount lowest to highest price in product page for variants, while having large number of variants
|
249 |
+
* Fix - Wrong discount price with tax in product page
|
250 |
+
* Feature - Skip/Apply first n number of products in product dependent rules(Pro)
|
251 |
+
|
252 |
= 1.5.9 - 18/04/18 =
|
253 |
* Feature - Free shipping option in cart rule(Pro)
|
254 |
|
view/view-pricing-rules.php
CHANGED
@@ -346,6 +346,8 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
346 |
$product_based_condition_product_quantity_to = isset($product_based_conditions['product_quantity_to']) ? $product_based_conditions['product_quantity_to'] : '';
|
347 |
$product_based_condition_product_to_buy = isset($product_based_conditions['product_to_buy']) ? $product_based_conditions['product_to_buy'] : array();
|
348 |
$product_based_condition_product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
|
|
|
|
349 |
?>
|
350 |
<div class="form-group" id="product_list">
|
351 |
<label ><?php esc_html_e('Buy', 'woo-discount-rules') ?></label>
|
@@ -371,8 +373,16 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
|
|
371 |
</div>
|
372 |
<div class="product_based_condition_get_product_discount">
|
373 |
<label ><?php esc_html_e('and get discount in ', 'woo-discount-rules') ?></label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
<?php echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_based_condition_product_to_apply, 'product_based_condition[product_to_apply]'); ?>
|
375 |
-
<label ><?php esc_html_e('Product(s)', 'woo-discount-rules') ?></label>
|
376 |
</div>
|
377 |
</div>
|
378 |
</div>
|
346 |
$product_based_condition_product_quantity_to = isset($product_based_conditions['product_quantity_to']) ? $product_based_conditions['product_quantity_to'] : '';
|
347 |
$product_based_condition_product_to_buy = isset($product_based_conditions['product_to_buy']) ? $product_based_conditions['product_to_buy'] : array();
|
348 |
$product_based_condition_product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
349 |
+
$product_based_condition_product_to_apply_count_option = isset($product_based_conditions['product_to_apply_count_option']) ? $product_based_conditions['product_to_apply_count_option'] : 'all';
|
350 |
+
$product_based_condition_product_to_apply_count = isset($product_based_conditions['product_to_apply_count']) ? $product_based_conditions['product_to_apply_count'] : '';
|
351 |
?>
|
352 |
<div class="form-group" id="product_list">
|
353 |
<label ><?php esc_html_e('Buy', 'woo-discount-rules') ?></label>
|
373 |
</div>
|
374 |
<div class="product_based_condition_get_product_discount">
|
375 |
<label ><?php esc_html_e('and get discount in ', 'woo-discount-rules') ?></label>
|
376 |
+
<select class="selectpicker" id="product_based_condition_product_to_apply_count_option" name="product_based_condition[product_to_apply_count_option]">
|
377 |
+
<option value="all"<?php echo ($product_based_condition_product_to_apply_count_option == 'all')? ' selected="selected"': ''; ?>><?php esc_html_e('All', 'woo-discount-rules') ?></option>
|
378 |
+
<option value="apply_first"<?php echo ($product_based_condition_product_to_apply_count_option == 'apply_first')? ' selected="selected"': ''; ?>><?php esc_html_e('First quantity(s)', 'woo-discount-rules') ?></option>
|
379 |
+
<option value="skip_first"<?php echo ($product_based_condition_product_to_apply_count_option == 'skip_first')? ' selected="selected"': ''; ?>><?php esc_html_e('Skip first quantity(s)', 'woo-discount-rules') ?></option>
|
380 |
+
</select>
|
381 |
+
<input placeholder="<?php esc_html_e('Quantity', 'woo-discount-rules') ?>" type="text" name="product_based_condition[product_to_apply_count]" id="product_based_condition_product_to_apply_count" value="<?php echo $product_based_condition_product_to_apply_count; ?>"/ >
|
382 |
+
</div>
|
383 |
+
<div class="product_based_condition_get_product_discount">
|
384 |
+
<label ><?php esc_html_e(' Product(s) ', 'woo-discount-rules') ?></label>
|
385 |
<?php echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_based_condition_product_to_apply, 'product_based_condition[product_to_apply]'); ?>
|
|
|
386 |
</div>
|
387 |
</div>
|
388 |
</div>
|
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.5.
|
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.5.10
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Requires at least: 4.6.1
|