modif hookOrderReturn

This commit is contained in:
Marion Muszynski 2016-04-25 11:13:36 +02:00
parent 4397a50151
commit 957c7f1db6

View File

@ -509,12 +509,17 @@ class Loyalty extends Module
$details = OrderReturn::getOrdersReturnDetail((int)($params['orderReturn']->id));
foreach ($details AS $detail)
{
$price = Db::getInstance()->getRow('
SELECT product_price * (1 + (tax_rate / 100)) price, product_quantity_discount
$orderDetail = Db::getInstance()->getRow('
SELECT product_price * (1 + (tax_rate / 100)) price, product_quantity_discount, reduction_percent
FROM '._DB_PREFIX_.'order_detail od
WHERE id_order_detail = '.(int)($detail['id_order_detail']));
$product_price = $price['product_quantity_discount']>0? $price['product_quantity_discount']:$price['price'];
if ($orderDetail['product_quantity_discount']>0) {
$product_price = $orderDetail['product_quantity_discount'];
} elseif ($orderDetail['reduction_percent']>0) {
$reduction = $price * ($orderDetail['reduction_percent'] / 100);
$product_price = $price - $reduction;
}
$totalPrice += ($product_price * $detail['product_quantity']);
}
$id_loyalty = LoyaltyModule::getByOrderId((int)($params['orderReturn']->id));
@ -681,7 +686,13 @@ class Loyalty extends Module
) {
return false;
}
$product_price = ($orderDetail->product_quantity_discount>0)?$orderDetail->product_quantity_discount:($orderDetail->product_price * (1 + $orderDetail->tax_rate / 100));
if ($orderDetail->product_quantity_discount>0) {
$product_price = $orderDetail->product_quantity_discount;
} elseif ($orderDetail->reduction_percent>0) {
$reduction = ($orderDetail->product_price * (1 + $orderDetail->tax_rate / 100)) * ($orderDetail->reduction_percent / 100);
$product_price = ($orderDetail->product_price * (1 + $orderDetail->tax_rate / 100)) - $reduction;
}
$price = (float)($product_price * $orderDetail->product_quantity_refunded);
$price = LoyaltyModule::getDiscountValueByPrice($price);
$price = $loyalty->discount_value - number_format($price, 2, '.', '');