notifications finish

This commit is contained in:
merdan 2022-07-05 18:01:13 +05:00
parent 6c7fa26a44
commit 7b179db9fe
2 changed files with 16 additions and 7 deletions

View File

@ -27,7 +27,7 @@ class OrderItemRepository extends WOrderItemRepo
}
if ($orderItem->qty_ordered) {
// $orderItem->total_weight -= $orderItem->weight * $orderItem->qty_to_cancel;
$orderItem->total_weight -= $orderItem->weight * $orderItem->qty_to_cancel;
$prosent_discount = ($orderItem->total* $orderItem->discount_percent)/100;
$base_prosent_discount = ($orderItem->base_total* $orderItem->discount_percent)/100;
$prosentsizDiscount = $orderItem->discount_amount - $prosent_discount;
@ -43,6 +43,7 @@ class OrderItemRepository extends WOrderItemRepo
$orderItem->save();
if ($orderItem->parent && $orderItem->parent->qty_ordered) {
$orderItem->parent->total_weight -= $orderItem->parent->weight * $orderItem->parent->qty_to_cancel;
$prosent_discount = ($orderItem->parent->total* $orderItem->parent->discount_percent)/100;
$base_prosent_discount = ($orderItem->parent->base_total* $orderItem->parent->discount_percent)/100;
$prosentsizDiscount = $orderItem->parent->discount_amount - $prosent_discount;
@ -59,6 +60,7 @@ class OrderItemRepository extends WOrderItemRepo
$orderItem->parent->save();
}
} else {
$orderItem->parent->total_weight -= $orderItem->parent->weight * $orderItem->parent->qty_to_cancel;
$prosent_discount = ($orderItem->parent->total* $orderItem->parent->discount_percent)/100;
$base_prosent_discount = ($orderItem->parent->base_total* $orderItem->parent->discount_percent)/100;
$prosentsizDiscount = $orderItem->parent->discount_amount - $prosent_discount;

View File

@ -67,14 +67,21 @@ class OrderRepository extends WOrderRepository
$total_weight = $order->items->sum('total_weight');
// $order_item->total_weight = ($order_item->qty_ordered - $order_item->qty_canceled) * $order_item->weight;
$shipping_price = $order->shipping_amount/$total_weight;
$base_shipping_price = $order->base_shipping_amount/$total_weight;
if(($total_weight - $order_item->total_weight) >0 ){
$shipping_price = $order->shipping_amount/$total_weight;
$base_shipping_price = $order->base_shipping_amount/$total_weight;
$canceled_amount = $shipping_price * $order_item->qty_to_cancel * $order_item->weight;
$canceled_base_amount = $base_shipping_price * $order_item->qty_to_cancel * $order_item->weight;
$canceled_amount = $shipping_price * $order_item->qty_to_cancel * $order_item->weight;
$canceled_base_amount = $base_shipping_price * $order_item->qty_to_cancel * $order_item->weight;
$order->shipping_amount = $order->shipping_amount - $canceled_amount;
$order->base_shipping_amount = $order->base_shipping_amount - $canceled_base_amount;
}else
{
$order->shipping_amount = 0;
$order->base_shipping_amount = 0;
}
$order->shipping_amount = $order->shipping_amount - $canceled_amount;
$order->base_shipping_amount = $order->base_shipping_amount - $canceled_base_amount;
return $order;
}