Version Description
- 13/03/18 =
- Fix - 500 error while having BOGO rules
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.5.4 |
Comparing to | |
See all releases |
Code changes from version 1.5.3 to 1.5.4
- includes/pricing-rules.php +206 -107
- loader.php +3 -0
- readme.txt +4 -1
- woo-discount-rules.php +1 -1
includes/pricing-rules.php
CHANGED
@@ -56,6 +56,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
56 |
|
57 |
public $postData;
|
58 |
|
|
|
|
|
59 |
public static $rules_loaded = 0;
|
60 |
public static $pricingRules;
|
61 |
|
@@ -418,14 +420,22 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
418 |
}
|
419 |
|
420 |
/**
|
421 |
-
* Apply the Rules to line items.
|
422 |
*
|
423 |
-
* @
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
{
|
427 |
global $woocommerce;
|
428 |
|
|
|
|
|
429 |
// If there is no rules, then return false.
|
430 |
if (!isset($this->rules)) return false;
|
431 |
|
@@ -435,58 +445,54 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
435 |
// To Generate Valid Rule sets.
|
436 |
$this->generateRuleSets($woocommerce);
|
437 |
// Sort cart by price ascending
|
438 |
-
|
439 |
-
$
|
440 |
-
|
441 |
-
|
442 |
-
if(
|
443 |
-
|
444 |
-
|
445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
}
|
447 |
-
|
448 |
-
|
449 |
-
if(
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
$empty_update_cart = $postData->get('update_cart');
|
461 |
-
$empty_proceed = $postData->get('proceed');
|
462 |
-
$runFreeProduct = (!empty($empty_apply_coupon) || !empty($empty_update_cart) || !empty($empty_proceed)) ? false : true;
|
463 |
-
$free_products = WC()->session->get('woo_discount_rules_get_free_product', array());
|
464 |
-
if(!empty($free_products) && $runFreeProduct){
|
465 |
-
//check if product already in cart
|
466 |
-
$cart = FlycartWoocommerceCart::get_cart();
|
467 |
-
if ( sizeof( $cart ) > 0 ) {
|
468 |
-
foreach ($free_products as $productId => $free_product_detail) {
|
469 |
-
$product = FlycartWoocommerceProduct::wc_get_product($productId);
|
470 |
-
$productParentId = FlycartWoocommerceProduct::get_parent_id($product);
|
471 |
-
if($productParentId){
|
472 |
-
FlycartWoocommerceCart::add_to_cart($productParentId, $free_product_detail['count'], $productId, FlycartWoocommerceProduct::get_attributes($product));
|
473 |
-
} else {
|
474 |
-
FlycartWoocommerceCart::add_to_cart($productId, $free_product_detail['count']);
|
475 |
}
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
}
|
487 |
-
$freeProductRule[0] = $this->formatRulesToApply($discountAmount, $free_product_detail['rule_name'], $cart_item_key, FlycartWoocommerceProduct::get_id($_product));
|
488 |
-
$this->matched_sets[$cart_item_key] = $freeProductRule;
|
489 |
}
|
|
|
490 |
}
|
491 |
}
|
492 |
}
|
@@ -494,50 +500,101 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
494 |
}
|
495 |
|
496 |
/**
|
497 |
-
*
|
|
|
|
|
|
|
|
|
|
|
498 |
* */
|
499 |
-
public function
|
500 |
-
$
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
$
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
//
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
}
|
534 |
}
|
535 |
}
|
536 |
}
|
537 |
}
|
538 |
}
|
539 |
-
|
540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
}
|
542 |
|
543 |
/**
|
@@ -739,13 +796,46 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
739 |
return $toApply;
|
740 |
}
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
/**
|
743 |
* Fetch back the Matched rules.
|
744 |
*
|
745 |
* @param $index
|
746 |
* @param array $item line item.
|
747 |
*/
|
748 |
-
public function matchRules($index, $item, $product_page = 0)
|
749 |
{
|
750 |
if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
|
751 |
$applied_rules = array();
|
@@ -753,9 +843,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
753 |
$i = 0;
|
754 |
if(!empty($this->rule_sets))
|
755 |
foreach ($this->rule_sets as $id => $rule) {
|
|
|
756 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
757 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
758 |
-
if($product_page){
|
759 |
//Check for product_discount to apply the rule only once
|
760 |
if(isset($rule['discount'])) {
|
761 |
if (!empty($rule['discount'])) {
|
@@ -775,7 +866,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
775 |
|
776 |
case 'specific_products':
|
777 |
if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
|
778 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
779 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
780 |
}
|
781 |
break;
|
@@ -807,7 +898,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
807 |
}
|
808 |
}
|
809 |
if(!$alreadyExists){
|
810 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
811 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
812 |
}
|
813 |
}
|
@@ -820,7 +911,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
820 |
$totalQuantityFromAllProducts = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
|
821 |
$quantity = $totalQuantityFromAllProducts;
|
822 |
}
|
823 |
-
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page);
|
824 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
825 |
}
|
826 |
|
@@ -1024,7 +1115,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1024 |
* @param $product_page
|
1025 |
* @return array|bool
|
1026 |
*/
|
1027 |
-
public function getAdjustmentAmount($quantity, $discount_ranges, $product_page)
|
1028 |
{
|
1029 |
$adjustment = array();
|
1030 |
foreach($discount_ranges as $discount_range) {
|
@@ -1063,20 +1154,28 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1063 |
$adjustment = $productCheapest ;
|
1064 |
}
|
1065 |
} else {
|
1066 |
-
//
|
1067 |
-
if(
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
$free_product[$productId]
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1075 |
}
|
1076 |
}
|
1077 |
-
if(!$product_page) WC()->session->set('woo_discount_rules_get_free_product', $free_product);
|
1078 |
}
|
1079 |
-
|
1080 |
}
|
1081 |
} else {
|
1082 |
$adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
|
56 |
|
57 |
public $postData;
|
58 |
|
59 |
+
public $bogo_matches;
|
60 |
+
|
61 |
public static $rules_loaded = 0;
|
62 |
public static $pricingRules;
|
63 |
|
420 |
}
|
421 |
|
422 |
/**
|
423 |
+
* Apply the Rules to line items for BOGO.
|
424 |
*
|
425 |
+
* @param string $cart_item_key
|
426 |
+
* @param int $product_id
|
427 |
+
* @param int $quantity
|
428 |
+
* @param int $variation_id
|
429 |
+
* @param array $variation
|
430 |
+
* @param array $cart_item_data
|
431 |
+
* @return boolean
|
432 |
+
* */
|
433 |
+
public function handleBOGODiscount($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data)
|
434 |
{
|
435 |
global $woocommerce;
|
436 |
|
437 |
+
$this->organizeRules();
|
438 |
+
|
439 |
// If there is no rules, then return false.
|
440 |
if (!isset($this->rules)) return false;
|
441 |
|
445 |
// To Generate Valid Rule sets.
|
446 |
$this->generateRuleSets($woocommerce);
|
447 |
// Sort cart by price ascending
|
448 |
+
$product_id_new = $product_id;
|
449 |
+
if($variation_id) $product_id_new = $variation_id;
|
450 |
+
$product = FlycartWoocommerceProduct::wc_get_product($product_id_new);
|
451 |
+
|
452 |
+
if(empty($cart_item_data)){
|
453 |
+
$cart_item_data = array_merge( $cart_item_data, array(
|
454 |
+
'key' => $cart_item_key,
|
455 |
+
'product_id' => $product_id,
|
456 |
+
'variation_id' => $variation_id,
|
457 |
+
'variation' => $variation,
|
458 |
+
'quantity' => $quantity,
|
459 |
+
'data' => $product,
|
460 |
+
) );
|
461 |
+
}
|
462 |
+
$carts = FlycartWoocommerceCart::get_cart();
|
463 |
+
if(!empty($carts)){
|
464 |
+
foreach ($carts as $cart_key => $cart){
|
465 |
+
if($cart_key == $cart_item_key){
|
466 |
+
$cart_item_data['quantity'] = $cart['quantity'];
|
467 |
+
}
|
468 |
+
}
|
469 |
}
|
470 |
+
$this->bogo_matches = array();
|
471 |
+
$this->matchRules($cart_item_key, $cart_item_data, 1, 1);
|
472 |
+
if(!empty($this->bogo_matches)){
|
473 |
+
if(count($this->bogo_matches) > 0){
|
474 |
+
foreach ($this->bogo_matches as $free_product_id => $bogo_match){
|
475 |
+
$found = false;
|
476 |
+
foreach ($carts as $cart_item) {
|
477 |
+
$cart_product_id = $cart_item['product_id'];
|
478 |
+
if($cart_item['variation_id']) $cart_product_id = $cart_item['variation_id'];
|
479 |
+
if ($free_product_id == $cart_product_id) {
|
480 |
+
$found = true;
|
481 |
+
break;
|
482 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
}
|
484 |
+
if ($found) {
|
485 |
+
continue;
|
486 |
+
} else {
|
487 |
+
remove_action('woocommerce_add_to_cart', array($this, 'handleBOGODiscount'));
|
488 |
+
$product = FlycartWoocommerceProduct::wc_get_product($free_product_id);
|
489 |
+
$productParentId = FlycartWoocommerceProduct::get_parent_id($product);
|
490 |
+
if($productParentId){
|
491 |
+
FlycartWoocommerceCart::add_to_cart($productParentId, $bogo_match['count'], $free_product_id, FlycartWoocommerceProduct::get_attributes($product));
|
492 |
+
} else {
|
493 |
+
FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
|
|
|
|
|
|
|
494 |
}
|
495 |
+
add_action('woocommerce_add_to_cart', array($this, 'handleBOGODiscount'), 10, 6);
|
496 |
}
|
497 |
}
|
498 |
}
|
500 |
}
|
501 |
|
502 |
/**
|
503 |
+
* Apply the Rules to line items for BOGO on quantity update.
|
504 |
+
*
|
505 |
+
* @param string $cart_item_key
|
506 |
+
* @param int $quantity
|
507 |
+
* @param int $old_quantity
|
508 |
+
* @param int $cart
|
509 |
* */
|
510 |
+
public function handleBOGODiscountOnUpdateQuantity($cart_item_key, $quantity, $old_quantity, $cart){
|
511 |
+
if(isset($cart->cart_contents) && !empty($cart->cart_contents)){
|
512 |
+
foreach ($cart->cart_contents as $cart_key => $cartItem){
|
513 |
+
if($cart_item_key == $cart_key){
|
514 |
+
$cart_data = $cartItem;
|
515 |
+
break;
|
516 |
+
}
|
517 |
+
}
|
518 |
+
if(!empty($cart_data)){
|
519 |
+
$carts = FlycartWoocommerceCart::get_cart();
|
520 |
+
if(!empty($carts)){
|
521 |
+
global $woocommerce;
|
522 |
+
|
523 |
+
$this->organizeRules();
|
524 |
+
|
525 |
+
// If there is no rules, then return false.
|
526 |
+
if (!isset($this->rules)) return false;
|
527 |
+
|
528 |
+
// Check point having list of checklist to apply.
|
529 |
+
if ($this->checkPoint()) return false;
|
530 |
+
|
531 |
+
// To Generate Valid Rule sets.
|
532 |
+
$this->generateRuleSets($woocommerce);
|
533 |
+
// Sort cart by price ascending
|
534 |
+
$product_id_new = $cart_data['product_id'];
|
535 |
+
if($cart_data['variation_id']) $product_id_new = $cart_data['variation_id'];
|
536 |
+
$this->bogo_matches = array();
|
537 |
+
$this->matchRules($cart_item_key, $cart_data, 1, 1);
|
538 |
+
if(!empty($this->bogo_matches)){
|
539 |
+
if(count($this->bogo_matches) > 0){
|
540 |
+
foreach ($this->bogo_matches as $free_product_id => $bogo_match){
|
541 |
+
$found = false;
|
542 |
+
foreach ($carts as $cart_item) {
|
543 |
+
$cart_product_id = $cart_item['product_id'];
|
544 |
+
if($cart_item['variation_id']) $cart_product_id = $cart_item['variation_id'];
|
545 |
+
if ($free_product_id == $cart_product_id) {
|
546 |
+
$found = true;
|
547 |
+
break;
|
548 |
+
}
|
549 |
+
}
|
550 |
+
if ($found) {
|
551 |
+
continue;
|
552 |
+
} else {
|
553 |
+
remove_action('woocommerce_after_cart_item_quantity_update', array($this, 'handleBOGODiscountOnUpdateQuantity'));
|
554 |
+
$product = FlycartWoocommerceProduct::wc_get_product($free_product_id);
|
555 |
+
$productParentId = FlycartWoocommerceProduct::get_parent_id($product);
|
556 |
+
if($productParentId){
|
557 |
+
FlycartWoocommerceCart::add_to_cart($productParentId, $bogo_match['count'], $free_product_id, FlycartWoocommerceProduct::get_attributes($product));
|
558 |
+
} else {
|
559 |
+
FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
|
560 |
+
}
|
561 |
+
add_action('woocommerce_after_cart_item_quantity_update', array($this, 'handleBOGODiscountOnUpdateQuantity'), 10, 4);
|
562 |
+
}
|
563 |
}
|
564 |
}
|
565 |
}
|
566 |
}
|
567 |
}
|
568 |
}
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Apply the Rules to line items.
|
573 |
+
*
|
574 |
+
* @return bool
|
575 |
+
*/
|
576 |
+
public function applyRules($product_page = 0)
|
577 |
+
{
|
578 |
+
global $woocommerce;
|
579 |
+
|
580 |
+
// If there is no rules, then return false.
|
581 |
+
if (!isset($this->rules)) return false;
|
582 |
+
|
583 |
+
// Check point having list of checklist to apply.
|
584 |
+
if ($this->checkPoint()) return false;
|
585 |
+
|
586 |
+
// To Generate Valid Rule sets.
|
587 |
+
$this->generateRuleSets($woocommerce);
|
588 |
+
// Sort cart by price ascending
|
589 |
+
|
590 |
+
$cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
|
591 |
+
|
592 |
+
$this->matched_sets = array();
|
593 |
+
foreach ($cart_contents as $index => $item) {
|
594 |
+
$this->matchRules($index, $item, $product_page);
|
595 |
+
}
|
596 |
+
|
597 |
+
$this->makeLog();
|
598 |
}
|
599 |
|
600 |
/**
|
796 |
return $toApply;
|
797 |
}
|
798 |
|
799 |
+
public function getBOGORules()
|
800 |
+
{
|
801 |
+
if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
|
802 |
+
$bogo_rules = array();
|
803 |
+
$i = 0;
|
804 |
+
if(!empty($this->rule_sets)){
|
805 |
+
foreach ($this->rule_sets as $id => $rule) {
|
806 |
+
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
807 |
+
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
808 |
+
//Check for product_discount to apply the rule only once
|
809 |
+
if(isset($rule['discount'])) {
|
810 |
+
if (!empty($rule['discount'])) {
|
811 |
+
$hasBOGO = 0;
|
812 |
+
foreach ($rule['discount'] as $discount_rules) {
|
813 |
+
if (isset($discount_rules->discount_type) && $discount_rules->discount_type == 'product_discount') {
|
814 |
+
$hasBOGO = 1;
|
815 |
+
}
|
816 |
+
}
|
817 |
+
if($hasBOGO){
|
818 |
+
$bogo_rules[] = $rule;
|
819 |
+
}
|
820 |
+
}
|
821 |
+
}
|
822 |
+
}
|
823 |
+
}
|
824 |
+
|
825 |
+
$i++;
|
826 |
+
}
|
827 |
+
}
|
828 |
+
|
829 |
+
return $bogo_rules;
|
830 |
+
}
|
831 |
+
|
832 |
/**
|
833 |
* Fetch back the Matched rules.
|
834 |
*
|
835 |
* @param $index
|
836 |
* @param array $item line item.
|
837 |
*/
|
838 |
+
public function matchRules($index, $item, $product_page = 0, $bogo = 0)
|
839 |
{
|
840 |
if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
|
841 |
$applied_rules = array();
|
843 |
$i = 0;
|
844 |
if(!empty($this->rule_sets))
|
845 |
foreach ($this->rule_sets as $id => $rule) {
|
846 |
+
$quantity = (isset($item['quantity']) ? $item['quantity'] : 0);
|
847 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
848 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
849 |
+
if($product_page && !$bogo){
|
850 |
//Check for product_discount to apply the rule only once
|
851 |
if(isset($rule['discount'])) {
|
852 |
if (!empty($rule['discount'])) {
|
866 |
|
867 |
case 'specific_products':
|
868 |
if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
|
869 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
870 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
871 |
}
|
872 |
break;
|
898 |
}
|
899 |
}
|
900 |
if(!$alreadyExists){
|
901 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
902 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
903 |
}
|
904 |
}
|
911 |
$totalQuantityFromAllProducts = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
|
912 |
$quantity = $totalQuantityFromAllProducts;
|
913 |
}
|
914 |
+
$discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
|
915 |
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
916 |
}
|
917 |
|
1115 |
* @param $product_page
|
1116 |
* @return array|bool
|
1117 |
*/
|
1118 |
+
public function getAdjustmentAmount($quantity, $discount_ranges, $product_page, $bogo)
|
1119 |
{
|
1120 |
$adjustment = array();
|
1121 |
foreach($discount_ranges as $discount_range) {
|
1154 |
$adjustment = $productCheapest ;
|
1155 |
}
|
1156 |
} else {
|
1157 |
+
//To handle BOGO
|
1158 |
+
if(!empty($productIds)) {
|
1159 |
+
if($bogo){
|
1160 |
+
$free_product = $this->bogo_matches;
|
1161 |
+
foreach ($productIds as $productId){
|
1162 |
+
if(isset($free_product[$productId])){
|
1163 |
+
$free_product[$productId]['count'] = $free_product[$productId]['count']+1;
|
1164 |
+
} else {
|
1165 |
+
$free_product[$productId]['count'] = 1;
|
1166 |
+
$free_product[$productId]['rule_name'] = $range->title;
|
1167 |
+
}
|
1168 |
+
}
|
1169 |
+
$this->bogo_matches = $free_product;
|
1170 |
+
$adjustment[$type] = $productIds;
|
1171 |
+
} else {
|
1172 |
+
$productCheapest = $this->getMoreThanOneCheapestProductFromCart($productIds, 1, count($productIds), $range);
|
1173 |
+
if (!empty($productCheapest)) {
|
1174 |
+
$adjustment = $productCheapest;
|
1175 |
}
|
1176 |
}
|
|
|
1177 |
}
|
1178 |
+
|
1179 |
}
|
1180 |
} else {
|
1181 |
$adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
|
loader.php
CHANGED
@@ -144,6 +144,9 @@ if(!class_exists('FlycartWooDiscountRules')){
|
|
144 |
add_action('woocommerce_cart_loaded_from_session', array($this->discountBase, 'handleDiscount'), 100);
|
145 |
}
|
146 |
|
|
|
|
|
|
|
147 |
// Manually Update Line Item Name.
|
148 |
add_filter('woocommerce_cart_item_name', array($this->discountBase, 'modifyName'));
|
149 |
|
144 |
add_action('woocommerce_cart_loaded_from_session', array($this->discountBase, 'handleDiscount'), 100);
|
145 |
}
|
146 |
|
147 |
+
add_action('woocommerce_add_to_cart', array($this->pricingRules, 'handleBOGODiscount'), 10, 6);
|
148 |
+
add_action( 'woocommerce_after_cart_item_quantity_update', array($this->pricingRules, 'handleBOGODiscountOnUpdateQuantity'), 10, 4 );
|
149 |
+
|
150 |
// Manually Update Line Item Name.
|
151 |
add_filter('woocommerce_cart_item_name', array($this->discountBase, 'modifyName'));
|
152 |
|
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 |
|
@@ -241,6 +241,9 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
241 |
|
242 |
== Changelog ==
|
243 |
|
|
|
|
|
|
|
244 |
= 1.5.3 - 09/03/18 =
|
245 |
* Feature - Cumulative option for apply to all products in Pricing rules
|
246 |
|
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.4
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
+
= 1.5.4 - 13/03/18 =
|
245 |
+
* Fix - 500 error while having BOGO rules
|
246 |
+
|
247 |
= 1.5.3 - 09/03/18 =
|
248 |
* Feature - Cumulative option for apply to all products in Pricing rules
|
249 |
|
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.4
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Requires at least: 4.6.1
|