Created
December 2, 2015 06:37
-
-
Save alpharder/34cffa92e65bf3e50736 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/addons/reward_points/func.php b/app/addons/reward_points/func.php | |
index f23a317..98a5e8d 100644 | |
--- a/app/addons/reward_points/func.php | |
+++ b/app/addons/reward_points/func.php | |
@@ -164,8 +164,10 @@ function fn_reward_points_calculate_cart_taxes_pre(&$cart, &$cart_products, &$sh | |
if (isset($cart_products[$k]['points_info']['raw_price'])) { | |
$product_price_in_points = $price_coef * $cart_products[$k]['points_info']['raw_price']; | |
$cart['products'][$k]['extra']['points_info']['raw_price'] = $product_price_in_points; | |
- $cart['products'][$k]['extra']['points_info']['display_price'] = $cart['products'][$k]['extra']['points_info']['price'] = round($product_price_in_points); | |
- $cart['points_info']['total_price'] = (isset($cart['points_info']['total_price']) ? $cart['points_info']['total_price'] : 0) + $product_price_in_points; | |
+ $cart['products'][$k]['extra']['points_info']['display_price'] = $cart['products'][$k]['extra']['points_info']['price'] = ceil($product_price_in_points); | |
+ $cart['points_info']['total_price'] = | |
+ (isset($cart['points_info']['total_price']) ? $cart['points_info']['total_price'] : 0) | |
+ + $product_price_in_points; | |
} | |
} | |
} | |
@@ -248,14 +250,14 @@ function fn_set_point_payment(&$cart, &$cart_products, &$auth) | |
// pick previously applied points before update | |
$cost_covered_by_applied_points = !empty($cart['points_info']['in_use']['cost']) ? $cart['points_info']['in_use']['cost'] : 0; | |
- $point_rate = floatval(Registry::get('addons.reward_points.point_rate')); | |
+ $point_exchange_rate = floatval(Registry::get('addons.reward_points.point_rate')); | |
if (defined('ORDER_MANAGEMENT')) { | |
$user_points = fn_get_user_additional_data(POINTS, $auth['user_id']) + (!empty($cart['previous_points_info']['in_use']['points']) ? $cart['previous_points_info']['in_use']['points'] : 0); | |
} else { | |
$user_points = !empty($user_info) ? $user_info['points'] : 0; | |
} | |
- if ($point_rate * $user_points * floatval($cart['subtotal']) > 0) { | |
+ if ($point_exchange_rate * $user_points * floatval($cart['subtotal']) > 0) { | |
$points_in_use = $cart['points_info']['in_use']['points']; | |
if ($points_in_use > $user_points) { | |
$points_in_use = $user_points; | |
@@ -277,8 +279,12 @@ function fn_set_point_payment(&$cart, &$cart_products, &$auth) | |
foreach ($cart['products'] as $cart_id=>$v) { | |
if (isset($v['extra']['points_info']['price'])) { | |
- $all_points = ($points_in_use == $cart['points_info']['total_price'] || $points_in_use == floor($cart['points_info']['raw_total_price'])) ? $points_in_use : $cart['points_info']['raw_total_price']; | |
- $discount = $points_in_use / $all_points * $cart_products[$cart_id]['subtotal'] * $subtotal_discount_coef; | |
+ $all_points = ($points_in_use == $cart['points_info']['total_price']) | |
+ ? $cart['points_info']['total_price'] | |
+ : $cart['points_info']['raw_total_price']; | |
+ | |
+ $discount = ($points_in_use / $all_points) * $cart_products[$cart_id]['subtotal'] * $subtotal_discount_coef; | |
+ | |
$cart['products'][$cart_id]['extra']['points_info']['discount'] = fn_format_price($discount); | |
$cost += $discount; | |
} | |
@@ -712,7 +718,7 @@ function fn_calculate_product_price_in_points(&$product, &$auth, $get_point_info | |
} | |
$product['points_info']['raw_price'] = $per * $subtotal; | |
- $product['points_info']['price'] = round($product['points_info']['raw_price']); | |
+ $product['points_info']['price'] = ceil($product['points_info']['raw_price']); | |
} | |
function fn_reward_points_clone_product(&$from_product_id, &$to_product_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment