Version Description
- 22/01/18 =
- Feature - Option: Exclude product for all products and specific categories option in Pricing Rules
- Fix - Strike and display price of least and highest amount for variable products
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.4.40 |
Comparing to | |
See all releases |
Code changes from version 1.4.39 to 1.4.40
- assets/js/app.js +4 -14
- helper/general-helper.php +18 -0
- includes/pricing-rules.php +99 -19
- loader.php +2 -1
- readme.txt +5 -1
- view/view-pricing-rules.php +15 -0
- woo-discount-rules.php +1 -1
assets/js/app.js
CHANGED
@@ -30,20 +30,6 @@ function validateFields(){
|
|
30 |
//--------------------------------------------PRICING RULES-----------------------------------------------------
|
31 |
//--------------------------------------------------------------------------------------------------------------
|
32 |
|
33 |
-
|
34 |
-
// Manage Product Selection ON-LOAD
|
35 |
-
var active_selection = $('#apply_to').val();
|
36 |
-
if (active_selection == 'specific_products') {
|
37 |
-
$('#product_list').css('display', 'block');
|
38 |
-
$('#category_list').css('display', 'none');
|
39 |
-
} else if (active_selection == 'specific_category') {
|
40 |
-
$('#product_list').css('display', 'none');
|
41 |
-
$('#category_list').css('display', 'block');
|
42 |
-
} else {
|
43 |
-
$('#product_list').css('display', 'none');
|
44 |
-
$('#category_list').css('display', 'none');
|
45 |
-
}
|
46 |
-
|
47 |
// Manage Customer Selection ON-LOAD
|
48 |
var user_selection = $('#apply_customer').val();
|
49 |
if (user_selection == 'only_given') {
|
@@ -265,14 +251,18 @@ function validateFields(){
|
|
265 |
if (option == 'specific_products') {
|
266 |
$('#product_list').css('display', 'block');
|
267 |
$('#category_list').css('display', 'none');
|
|
|
268 |
} else if (option == 'specific_category') {
|
269 |
$('#product_list').css('display', 'none');
|
270 |
$('#category_list').css('display', 'block');
|
|
|
271 |
} else {
|
272 |
$('#product_list').css('display', 'none');
|
273 |
$('#category_list').css('display', 'none');
|
|
|
274 |
}
|
275 |
});
|
|
|
276 |
|
277 |
// Manage the Customer.
|
278 |
$('#apply_customer').on('change', function () {
|
30 |
//--------------------------------------------PRICING RULES-----------------------------------------------------
|
31 |
//--------------------------------------------------------------------------------------------------------------
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
// Manage Customer Selection ON-LOAD
|
34 |
var user_selection = $('#apply_customer').val();
|
35 |
if (user_selection == 'only_given') {
|
251 |
if (option == 'specific_products') {
|
252 |
$('#product_list').css('display', 'block');
|
253 |
$('#category_list').css('display', 'none');
|
254 |
+
$('#product_exclude_list').hide();
|
255 |
} else if (option == 'specific_category') {
|
256 |
$('#product_list').css('display', 'none');
|
257 |
$('#category_list').css('display', 'block');
|
258 |
+
$('#product_exclude_list').show();
|
259 |
} else {
|
260 |
$('#product_list').css('display', 'none');
|
261 |
$('#category_list').css('display', 'none');
|
262 |
+
$('#product_exclude_list').show();
|
263 |
}
|
264 |
});
|
265 |
+
$('#apply_to').trigger('change');
|
266 |
|
267 |
// Manage the Customer.
|
268 |
$('#apply_customer').on('change', function () {
|
helper/general-helper.php
CHANGED
@@ -361,5 +361,23 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
|
|
361 |
|
362 |
return $html;
|
363 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
}
|
365 |
}
|
361 |
|
362 |
return $html;
|
363 |
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Check do the discount rules need to execute
|
367 |
+
* */
|
368 |
+
public static function doIHaveToRun(){
|
369 |
+
$status = true;
|
370 |
+
if(is_admin()){
|
371 |
+
$status = false;
|
372 |
+
}
|
373 |
+
if(defined('DOING_AJAX') && DOING_AJAX){
|
374 |
+
$status = true;
|
375 |
+
}
|
376 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
|
377 |
+
$status = false;
|
378 |
+
}
|
379 |
+
|
380 |
+
return $status;
|
381 |
+
}
|
382 |
}
|
383 |
}
|
includes/pricing-rules.php
CHANGED
@@ -141,7 +141,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
141 |
'discount_range',
|
142 |
'product_based_condition',
|
143 |
'product_based_discount',
|
144 |
-
'rule_order'
|
|
|
145 |
);
|
146 |
|
147 |
//----------------------------------------------------------------------------------------------------------
|
@@ -224,10 +225,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
224 |
$request['product_based_discount'] = '{}';
|
225 |
}
|
226 |
|
|
|
|
|
227 |
$request['status'] = 'publish';
|
228 |
|
229 |
if (is_null($id) || !isset($id)) return false;
|
230 |
-
|
231 |
foreach ($request as $index => $value) {
|
232 |
if (in_array($index, $form)) {
|
233 |
if (get_post_meta($id, $index)) {
|
@@ -264,10 +266,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
264 |
/**
|
265 |
* To Analyzing the Pricing Rules to Apply the Discount in terms of price.
|
266 |
*/
|
267 |
-
public function analyse($woocommerce)
|
268 |
{
|
269 |
$this->organizeRules();
|
270 |
-
$this->applyRules();
|
271 |
$this->initAdjustment();
|
272 |
}
|
273 |
|
@@ -412,7 +414,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
412 |
*
|
413 |
* @return bool
|
414 |
*/
|
415 |
-
public function applyRules()
|
416 |
{
|
417 |
global $woocommerce;
|
418 |
|
@@ -432,7 +434,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
432 |
$free_product_quantity_exists = $this->reduceCartItemQuantityIfFreeProductExistsAlready();
|
433 |
|
434 |
foreach ($cart_contents as $index => $item) {
|
435 |
-
$this->matchRules($index, $item);
|
436 |
}
|
437 |
|
438 |
//to handle buy one get one
|
@@ -585,8 +587,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
585 |
} else {
|
586 |
$rule_sets[$index]['type']['is_cumulative'] = 0;
|
587 |
}
|
|
|
588 |
} else {
|
|
|
589 |
$rule_sets[$index]['type'] = 'all';
|
|
|
590 |
}
|
591 |
|
592 |
$rule_sets[$index]['discount'] = 0;
|
@@ -737,6 +742,20 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
737 |
foreach ($this->rule_sets as $id => $rule) {
|
738 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
739 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
|
741 |
// Working with Products and Category.
|
742 |
switch ($rule['apply_to']) {
|
@@ -749,7 +768,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
749 |
break;
|
750 |
|
751 |
case 'specific_category':
|
752 |
-
|
|
|
753 |
$alreadyExists = 0;
|
754 |
if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
|
755 |
$totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category']);
|
@@ -782,8 +802,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
782 |
|
783 |
case 'all_products':
|
784 |
default:
|
785 |
-
|
786 |
-
|
|
|
|
|
|
|
787 |
break;
|
788 |
}
|
789 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
@@ -1336,18 +1359,23 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1336 |
if ($rule->category_to_apply == null) $status = true;
|
1337 |
|
1338 |
if ($rule->category_to_apply != null) {
|
|
|
1339 |
$category_to_apply = json_decode($rule->category_to_apply);
|
1340 |
if (isset($rule->apply_child_categories) && $rule->apply_child_categories == 1) {
|
1341 |
$category_to_apply = $this->getAllSubCategories($category_to_apply);
|
1342 |
}
|
1343 |
FlycartWooDiscountRulesGeneralHelper::toInt($category_to_apply);
|
1344 |
$status = false;
|
1345 |
-
if
|
1346 |
-
$
|
1347 |
-
|
|
|
1348 |
}
|
1349 |
} else if ($rule->apply_to == 'all_products') {
|
1350 |
-
$
|
|
|
|
|
|
|
1351 |
}
|
1352 |
|
1353 |
// check for user roles
|
@@ -1388,6 +1416,22 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1388 |
return $discount_range;
|
1389 |
}
|
1390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1391 |
public function getTextForProductDiscountCondition($rule){
|
1392 |
$product_based_conditions = json_decode((isset($rule->product_based_condition) ? $rule->product_based_condition : '{}'), true);
|
1393 |
$product_buy_type = isset($product_based_conditions['product_buy_type']) ? $product_based_conditions['product_buy_type'] : 'any';
|
@@ -1581,7 +1625,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1581 |
// If Product having the rule sets then,
|
1582 |
if (!isset($this->matched_sets[$cart_item_key])) return false;
|
1583 |
if (empty($this->matched_sets[$cart_item_key])) return false;
|
1584 |
-
|
1585 |
$adjustment_set = $this->matched_sets[$cart_item_key];
|
1586 |
$product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
|
1587 |
$price = FlycartWoocommerceProduct::get_price($product);
|
@@ -1760,7 +1804,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1760 |
{
|
1761 |
if(FlycartWoocommerceVersion::wcVersion('3.0')) return $data;
|
1762 |
$item_price = $data['price_html'];
|
1763 |
-
$notAdmin =
|
1764 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'dont';
|
1765 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1766 |
$discountPrice = $this->getDiscountPriceForTheProduct($product, FlycartWoocommerceProduct::get_price($variations));
|
@@ -1781,12 +1825,13 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1781 |
* */
|
1782 |
public function replaceVisiblePrices($item_price, $product)
|
1783 |
{
|
1784 |
-
$notAdmin =
|
1785 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'dont';
|
1786 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1787 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
1788 |
if($discountPrice > 0){
|
1789 |
$price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
|
|
|
1790 |
$item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
|
1791 |
$item_price = '<span class="cart_price"><del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix() . '</ins></span>';
|
1792 |
}
|
@@ -1795,11 +1840,46 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1795 |
return $item_price;
|
1796 |
}
|
1797 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1798 |
/**
|
1799 |
* Display Product sale tag on the product page
|
1800 |
* */
|
1801 |
public function displayProductIsOnSaleTag($on_sale, $product){
|
1802 |
-
$notAdmin =
|
1803 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'dont';
|
1804 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1805 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
@@ -1820,7 +1900,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1820 |
$item['data'] = $product;
|
1821 |
$item['quantity'] = ($this->getQuantityOfProductInCart($product_id))+1;
|
1822 |
global $woocommerce;
|
1823 |
-
$this->analyse($woocommerce);
|
1824 |
$this->matchRules($product_id, $item, 1);
|
1825 |
if(isset($this->matched_sets[$product_id])){
|
1826 |
if($variationPrice){
|
@@ -1872,7 +1952,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1872 |
}
|
1873 |
}
|
1874 |
}
|
1875 |
-
|
1876 |
$amount = 0;
|
1877 |
$discount = 0;
|
1878 |
if ($type == 'first') {
|
141 |
'discount_range',
|
142 |
'product_based_condition',
|
143 |
'product_based_discount',
|
144 |
+
'rule_order',
|
145 |
+
'product_to_exclude'
|
146 |
);
|
147 |
|
148 |
//----------------------------------------------------------------------------------------------------------
|
225 |
$request['product_based_discount'] = '{}';
|
226 |
}
|
227 |
|
228 |
+
if(!isset($request['product_to_exclude'])) $request['product_to_exclude'] = array();
|
229 |
+
|
230 |
$request['status'] = 'publish';
|
231 |
|
232 |
if (is_null($id) || !isset($id)) return false;
|
|
|
233 |
foreach ($request as $index => $value) {
|
234 |
if (in_array($index, $form)) {
|
235 |
if (get_post_meta($id, $index)) {
|
266 |
/**
|
267 |
* To Analyzing the Pricing Rules to Apply the Discount in terms of price.
|
268 |
*/
|
269 |
+
public function analyse($woocommerce, $product_page = 0)
|
270 |
{
|
271 |
$this->organizeRules();
|
272 |
+
$this->applyRules($product_page);
|
273 |
$this->initAdjustment();
|
274 |
}
|
275 |
|
414 |
*
|
415 |
* @return bool
|
416 |
*/
|
417 |
+
public function applyRules($product_page = 0)
|
418 |
{
|
419 |
global $woocommerce;
|
420 |
|
434 |
$free_product_quantity_exists = $this->reduceCartItemQuantityIfFreeProductExistsAlready();
|
435 |
|
436 |
foreach ($cart_contents as $index => $item) {
|
437 |
+
$this->matchRules($index, $item, $product_page);
|
438 |
}
|
439 |
|
440 |
//to handle buy one get one
|
587 |
} else {
|
588 |
$rule_sets[$index]['type']['is_cumulative'] = 0;
|
589 |
}
|
590 |
+
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
591 |
} else {
|
592 |
+
|
593 |
$rule_sets[$index]['type'] = 'all';
|
594 |
+
$rule_sets[$index]['product_to_exclude'] = $this->getExcludeProductsFromRule($rule);
|
595 |
}
|
596 |
|
597 |
$rule_sets[$index]['discount'] = 0;
|
742 |
foreach ($this->rule_sets as $id => $rule) {
|
743 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
744 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
745 |
+
if($product_page){
|
746 |
+
//Check for product_discount to apply the rule only once
|
747 |
+
if(isset($rule['discount'])) {
|
748 |
+
if (!empty($rule['discount'])) {
|
749 |
+
$hasBOGO = 0;
|
750 |
+
foreach ($rule['discount'] as $discount_rules) {
|
751 |
+
if (isset($discount_rules->discount_type) && $discount_rules->discount_type == 'product_discount') {
|
752 |
+
$hasBOGO = 1;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
if($hasBOGO) continue;
|
756 |
+
}
|
757 |
+
}
|
758 |
+
}
|
759 |
|
760 |
// Working with Products and Category.
|
761 |
switch ($rule['apply_to']) {
|
768 |
break;
|
769 |
|
770 |
case 'specific_category':
|
771 |
+
$notInProductList = !$this->isItemInProductList($rule['product_to_exclude'], $item);
|
772 |
+
if ($this->isItemInCategoryList($rule['type']['specific_category'], $item) && $notInProductList) {
|
773 |
$alreadyExists = 0;
|
774 |
if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
|
775 |
$totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category']);
|
802 |
|
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 |
+
|
810 |
break;
|
811 |
}
|
812 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
1359 |
if ($rule->category_to_apply == null) $status = true;
|
1360 |
|
1361 |
if ($rule->category_to_apply != null) {
|
1362 |
+
$productToExclude = $this->getExcludeProductsFromRule($rule);
|
1363 |
$category_to_apply = json_decode($rule->category_to_apply);
|
1364 |
if (isset($rule->apply_child_categories) && $rule->apply_child_categories == 1) {
|
1365 |
$category_to_apply = $this->getAllSubCategories($category_to_apply);
|
1366 |
}
|
1367 |
FlycartWooDiscountRulesGeneralHelper::toInt($category_to_apply);
|
1368 |
$status = false;
|
1369 |
+
if(!in_array($id, $productToExclude))
|
1370 |
+
if (count(array_intersect($category_to_apply, $category)) > 0) {
|
1371 |
+
$status = true;
|
1372 |
+
}
|
1373 |
}
|
1374 |
} else if ($rule->apply_to == 'all_products') {
|
1375 |
+
$productToExclude = $this->getExcludeProductsFromRule($rule);
|
1376 |
+
$status = false;
|
1377 |
+
if(!in_array($id, $productToExclude))
|
1378 |
+
$status = true;
|
1379 |
}
|
1380 |
|
1381 |
// check for user roles
|
1416 |
return $discount_range;
|
1417 |
}
|
1418 |
|
1419 |
+
/**
|
1420 |
+
* To get product to exclude
|
1421 |
+
* */
|
1422 |
+
public function getExcludeProductsFromRule($rule){
|
1423 |
+
$productToExclude = array();
|
1424 |
+
if(is_array($rule->product_to_exclude)) $productToExclude = $rule->product_to_exclude;
|
1425 |
+
else if(is_string($rule->product_to_exclude)){
|
1426 |
+
$productToExclude = json_decode($rule->product_to_exclude);
|
1427 |
+
$productToExclude = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($productToExclude);
|
1428 |
+
}
|
1429 |
+
if(!is_array($productToExclude)){
|
1430 |
+
$productToExclude = array();
|
1431 |
+
}
|
1432 |
+
return $productToExclude;
|
1433 |
+
}
|
1434 |
+
|
1435 |
public function getTextForProductDiscountCondition($rule){
|
1436 |
$product_based_conditions = json_decode((isset($rule->product_based_condition) ? $rule->product_based_condition : '{}'), true);
|
1437 |
$product_buy_type = isset($product_based_conditions['product_buy_type']) ? $product_based_conditions['product_buy_type'] : 'any';
|
1625 |
// If Product having the rule sets then,
|
1626 |
if (!isset($this->matched_sets[$cart_item_key])) return false;
|
1627 |
if (empty($this->matched_sets[$cart_item_key])) return false;
|
1628 |
+
|
1629 |
$adjustment_set = $this->matched_sets[$cart_item_key];
|
1630 |
$product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
|
1631 |
$price = FlycartWoocommerceProduct::get_price($product);
|
1804 |
{
|
1805 |
if(FlycartWoocommerceVersion::wcVersion('3.0')) return $data;
|
1806 |
$item_price = $data['price_html'];
|
1807 |
+
$notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
|
1808 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'dont';
|
1809 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1810 |
$discountPrice = $this->getDiscountPriceForTheProduct($product, FlycartWoocommerceProduct::get_price($variations));
|
1825 |
* */
|
1826 |
public function replaceVisiblePrices($item_price, $product)
|
1827 |
{
|
1828 |
+
$notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
|
1829 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'dont';
|
1830 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1831 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
1832 |
if($discountPrice > 0){
|
1833 |
$price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
|
1834 |
+
$price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display);
|
1835 |
$item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
|
1836 |
$item_price = '<span class="cart_price"><del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix() . '</ins></span>';
|
1837 |
}
|
1840 |
return $item_price;
|
1841 |
}
|
1842 |
|
1843 |
+
public function checkForHighestVariantIfExists($product, $price_to_display){
|
1844 |
+
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
1845 |
+
$child_prices = array();
|
1846 |
+
$children = array_filter( array_map( 'wc_get_product', FlycartWoocommerceProduct::get_children($product) ), 'wc_products_array_filter_visible_grouped' );
|
1847 |
+
|
1848 |
+
foreach ( $children as $child ) {
|
1849 |
+
if ( '' !== FlycartWoocommerceProduct::get_price($child) ) {
|
1850 |
+
$child_prices[FlycartWoocommerceProduct::get_id($child)] = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($child) : FlycartWoocommerceProduct::get_price_excluding_tax( $child );
|
1851 |
+
}
|
1852 |
+
}
|
1853 |
+
$maxProductId = 0;
|
1854 |
+
if ( ! empty( $child_prices ) ) {
|
1855 |
+
$min_price = min( $child_prices );
|
1856 |
+
$max_price = max( $child_prices );
|
1857 |
+
if($min_price != $max_price){
|
1858 |
+
$maxProductIds = array_keys($child_prices, $max_price);
|
1859 |
+
if(isset($maxProductIds[0]))
|
1860 |
+
$maxProductId = $maxProductIds[0];
|
1861 |
+
}
|
1862 |
+
}
|
1863 |
+
|
1864 |
+
if($maxProductId){
|
1865 |
+
$maxProduct = FlycartWoocommerceProduct::wc_get_product($maxProductId);
|
1866 |
+
$greatestDiscountPrice = $this->getDiscountPriceForTheProduct($maxProduct);
|
1867 |
+
if($greatestDiscountPrice > 0){
|
1868 |
+
$greatestDiscountPrice = FlycartWoocommerceProduct::wc_price($greatestDiscountPrice);
|
1869 |
+
} else {
|
1870 |
+
$greatestDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($maxProduct));
|
1871 |
+
}
|
1872 |
+
$price_to_display .= ' - '.$greatestDiscountPrice;
|
1873 |
+
}
|
1874 |
+
|
1875 |
+
return $price_to_display;
|
1876 |
+
}
|
1877 |
+
|
1878 |
/**
|
1879 |
* Display Product sale tag on the product page
|
1880 |
* */
|
1881 |
public function displayProductIsOnSaleTag($on_sale, $product){
|
1882 |
+
$notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
|
1883 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'dont';
|
1884 |
if($show_price_discount_on_product_page == 'show' && $notAdmin){
|
1885 |
$discountPrice = $this->getDiscountPriceForTheProduct($product);
|
1900 |
$item['data'] = $product;
|
1901 |
$item['quantity'] = ($this->getQuantityOfProductInCart($product_id))+1;
|
1902 |
global $woocommerce;
|
1903 |
+
$this->analyse($woocommerce, 1);
|
1904 |
$this->matchRules($product_id, $item, 1);
|
1905 |
if(isset($this->matched_sets[$product_id])){
|
1906 |
if($variationPrice){
|
1952 |
}
|
1953 |
}
|
1954 |
}
|
1955 |
+
|
1956 |
$amount = 0;
|
1957 |
$discount = 0;
|
1958 |
if ($type == 'first') {
|
loader.php
CHANGED
@@ -53,7 +53,8 @@ if(!class_exists('FlycartWooDiscountRules')){
|
|
53 |
$this->pricingRules = new FlycartWooDiscountRulesPricingRules();
|
54 |
if (is_admin()) {
|
55 |
$this->loadAdminScripts();
|
56 |
-
}
|
|
|
57 |
$this->loadSiteScripts();
|
58 |
}
|
59 |
}
|
53 |
$this->pricingRules = new FlycartWooDiscountRulesPricingRules();
|
54 |
if (is_admin()) {
|
55 |
$this->loadAdminScripts();
|
56 |
+
}
|
57 |
+
if(FlycartWooDiscountRulesGeneralHelper::doIHaveToRun()){
|
58 |
$this->loadSiteScripts();
|
59 |
}
|
60 |
}
|
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 |
|
@@ -238,6 +238,10 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
238 |
|
239 |
== Changelog ==
|
240 |
|
|
|
|
|
|
|
|
|
241 |
= 1.4.39 - 12/01/18 =
|
242 |
* Feature - Option: Any one of cheapest from all products for BOGO(Pro version)
|
243 |
* Fix - Improvement in loading issue in product list page
|
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.40
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
238 |
|
239 |
== Changelog ==
|
240 |
|
241 |
+
= 1.4.40 - 22/01/18 =
|
242 |
+
* Feature - Option: Exclude product for all products and specific categories option in Pricing Rules
|
243 |
+
* Fix - Strike and display price of least and highest amount for variable products
|
244 |
+
|
245 |
= 1.4.39 - 12/01/18 =
|
246 |
* Feature - Option: Any one of cheapest from all products for BOGO(Pro version)
|
247 |
* Fix - Improvement in loading issue in product list page
|
view/view-pricing-rules.php
CHANGED
@@ -177,6 +177,21 @@ $rule_id = (isset($data->ID)) ? $data->ID : 0;
|
|
177 |
</div>
|
178 |
</div>
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
<div class="form-group">
|
181 |
<div class="row">
|
182 |
<div class="col-md-3"><label> Customers </label></div>
|
177 |
</div>
|
178 |
</div>
|
179 |
|
180 |
+
<div class="form-group" id="product_exclude_list">
|
181 |
+
<div class="row">
|
182 |
+
<div class="col-md-3"><label><?php esc_html_e('Exclude products', 'woo-discount-rules'); ?></label></div>
|
183 |
+
<div class="col-md-6">
|
184 |
+
<?php
|
185 |
+
if(is_array($data->product_to_exclude))
|
186 |
+
$product_exclude_list = $data->product_to_exclude;
|
187 |
+
else
|
188 |
+
$product_exclude_list = json_decode((isset($data->product_to_exclude) ? $data->product_to_exclude : '{}'), true);
|
189 |
+
echo FlycartWoocommerceProduct::getProductAjaxSelectBox($product_exclude_list, 'product_to_exclude');
|
190 |
+
?>
|
191 |
+
</div>
|
192 |
+
</div>
|
193 |
+
</div>
|
194 |
+
|
195 |
<div class="form-group">
|
196 |
<div class="row">
|
197 |
<div class="col-md-3"><label> Customers </label></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.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.40
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Requires at least: 4.6.1
|