Updated refund for new product types

This commit is contained in:
jitendra 2019-10-10 12:33:05 +05:30
parent c8505d3fbc
commit b707a855fc
2 changed files with 66 additions and 54 deletions

View File

@ -129,30 +129,38 @@ class RefundRepository extends Repository
'additional' => $orderItem->additional
]);
if ($orderItem->type == 'configurable' && $orderItem->child) {
$childOrderItem = $orderItem->child;
if ($orderItem->getTypeInstance()->isComposite()) {
foreach ($orderItem->children as $childOrderItem) {
$finalQty = $childOrderItem->qty_ordered
? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty
: $childOrderItem->qty_ordered;
$refundItem->child = $this->refundItemRepository->create([
'refund_id' => $refund->id,
'order_item_id' => $childOrderItem->id,
'parent_id' => $refundItem->id,
'name' => $childOrderItem->name,
'sku' => $childOrderItem->sku,
'qty' => $qty,
'price' => $childOrderItem->price,
'base_price' => $childOrderItem->base_price,
'total' => $childOrderItem->price * $qty,
'base_total' => $childOrderItem->base_price * $qty,
'tax_amount' => 0,
'base_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'product_id' => $childOrderItem->product_id,
'product_type' => $childOrderItem->product_type,
'additional' => $childOrderItem->additional
]);
$refundItem->child = $this->refundItemRepository->create([
'refund_id' => $refund->id,
'order_item_id' => $childOrderItem->id,
'parent_id' => $refundItem->id,
'name' => $childOrderItem->name,
'sku' => $childOrderItem->sku,
'qty' => $finalQty,
'price' => $childOrderItem->price,
'base_price' => $childOrderItem->base_price,
'total' => $childOrderItem->price * $finalQty,
'base_total' => $childOrderItem->base_price * $finalQty,
'tax_amount' => 0,
'base_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'product_id' => $childOrderItem->product_id,
'product_type' => $childOrderItem->product_type,
'additional' => $childOrderItem->additional
]);
if ($childOrderItem->product->getTypeInstance()->showQuantityBox())
$this->refundItemRepository->returnQtyToProductInventory($childOrderItem, $finalQty);
$this->orderItemRepository->collectTotals($childOrderItem);
}
$this->refundItemRepository->returnQtyToProductInventory($childOrderItem, $qty);
} else {
$this->refundItemRepository->returnQtyToProductInventory($orderItem, $qty);
}

View File

@ -31,37 +31,39 @@
</div>
<div style="display: flex;flex-direction: row;margin-top: 20px;justify-content: space-between;margin-bottom: 40px;">
<div style="line-height: 25px;">
<div style="font-weight: bold;font-size: 16px;color: #242424;">
{{ __('shop::app.mail.order.shipping-address') }}
</div>
@if ($order->shipping_address)
<div style="line-height: 25px;">
<div style="font-weight: bold;font-size: 16px;color: #242424;">
{{ __('shop::app.mail.order.shipping-address') }}
</div>
<div>
{{ $order->shipping_address->name }}
</div>
<div>
{{ $order->shipping_address->name }}
</div>
<div>
{{ $order->shipping_address->address1 }}, {{ $order->shipping_address->state }}
</div>
<div>
{{ $order->shipping_address->address1 }}, {{ $order->shipping_address->state }}
</div>
<div>
{{ core()->country_name($order->shipping_address->country) }} {{ $order->shipping_address->postcode }}
</div>
<div>
{{ core()->country_name($order->shipping_address->country) }} {{ $order->shipping_address->postcode }}
</div>
<div>---</div>
<div>---</div>
<div style="margin-bottom: 40px;">
{{ __('shop::app.mail.order.contact') }} : {{ $order->shipping_address->phone }}
</div>
<div style="margin-bottom: 40px;">
{{ __('shop::app.mail.order.contact') }} : {{ $order->shipping_address->phone }}
</div>
<div style="font-size: 16px;color: #242424;">
{{ __('shop::app.mail.order.shipping') }}
</div>
<div style="font-size: 16px;color: #242424;">
{{ __('shop::app.mail.order.shipping') }}
</div>
<div style="font-weight: bold;font-size: 16px;color: #242424;">
{{ $order->shipping_title }}
<div style="font-weight: bold;font-size: 16px;color: #242424;">
{{ $order->shipping_title }}
</div>
</div>
</div>
@endif
<div style="line-height: 25px;">
<div style="font-weight: bold;font-size: 16px;color: #242424;">
@ -113,6 +115,16 @@
<tr>
<td data-value="{{ __('shop::app.customer.account.order.view.product-name') }}" style="text-align: left;padding: 8px">
{{ $item->name }}
@if (isset($item->additional['attributes']))
<div class="item-options">
@foreach ($item->additional['attributes'] as $attribute)
<b>{{ $attribute['attribute_name'] }} : </b>{{ $attribute['option_label'] }}</br>
@endforeach
</div>
@endif
</td>
<td data-value="{{ __('shop::app.customer.account.order.view.price') }}" style="text-align: left;padding: 8px">
@ -122,14 +134,6 @@
<td data-value="{{ __('shop::app.customer.account.order.view.qty') }}" style="text-align: left;padding: 8px">
{{ $item->qty }}
</td>
@if ($html = $item->getOptionDetailHtml())
<div style="">
<label style="margin-top: 10px; font-size: 16px;color: #5E5E5E; display: block;">
{{ $html }}
</label>
</div>
@endif
</tr>
@endforeach
@ -146,7 +150,7 @@
</span>
</div>
@if ($refund->shipping_amount > 0)
@if ($order->shipping_address)
<div>
<span>{{ __('shop::app.mail.order.shipping-handling') }}</span>
<span style="float: right;">