Created
July 30, 2015 08:54
-
-
Save imakarov/b9402e2ac8a0e79e357b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/functions/fn.promotions.php b/app/functions/fn.promotions.php | |
index a934b0c..be160fe 100644 | |
--- a/app/functions/fn.promotions.php | |
+++ b/app/functions/fn.promotions.php | |
@@ -1346,18 +1346,17 @@ function fn_promotion_validate_product($promotion, $product, $cart_products) | |
if (!empty($cart_products)) { // cart promotion validated | |
foreach ($promotion['value'] as $p_v) { | |
- if ($p_v['product_id'] == $product['product_id'] && empty($p_v['product_options']) && $p_v['amount'] > 1) { | |
- $_amount = 0; | |
+ if ($p_v['product_id'] == $product['product_id'] | |
+ && empty($p_v['product_options']) | |
+ && $p_v['amount'] > 1 | |
+ ) { | |
+ $product['amount'] = 0; | |
foreach ($cart_products as $c_pr) { | |
if ($c_pr['product_id'] == $p_v['product_id']) { | |
- $_amount += $c_pr['amount']; | |
+ $product['amount'] += $c_pr['amount']; | |
} | |
} | |
- | |
- if ($_amount == $p_v['amount']) { | |
- $product['amount'] = $p_v['amount']; | |
- break; | |
- } | |
+ break; | |
} | |
} | |
} | |
@@ -1371,8 +1370,15 @@ function fn_promotion_validate_product($promotion, $product, $cart_products) | |
$upd_product = array('product_id' => $product['product_id'], 'amount' => $product['amount']); | |
} | |
foreach ($promotion['value'] as $p_v) { | |
- if ($upd_product['amount'] >= $p_v['amount']) { | |
- $upd_product['amount'] = $p_v['amount']; | |
+ if ($p_v['product_id'] == $upd_product['product_id']) { | |
+ if ( | |
+ !isset($upd_product['product_options'], $p_v['product_options']) | |
+ || (serialize($upd_product['product_options']) == serialize($p_v['product_options'])) | |
+ ) { | |
+ if ($upd_product['amount'] >= $p_v['amount']) { | |
+ $upd_product['amount'] = $p_v['amount']; | |
+ } | |
+ } | |
} | |
} | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment