diff --git a/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php
index 97c330575..feaf839ae 100755
--- a/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php
@@ -256,7 +256,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php
index 545590ea0..9f7acf974 100755
--- a/packages/Webkul/Checkout/src/Cart.php
+++ b/packages/Webkul/Checkout/src/Cart.php
@@ -870,6 +870,8 @@ class Cart {
if (isset($data['children']) && $data['children']) {
foreach ($data['children'] as $child) {
+ $child['quantity'] = $child['quantity'] ? $child['quantity'] * $data['quantity'] : $child['quantity'];
+
$finalData['children'][] = $this->prepareDataForOrderItem($child);
}
}
diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php
index cbb66f951..ff667b3df 100644
--- a/packages/Webkul/Product/src/Listeners/ProductFlat.php
+++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php
@@ -273,9 +273,8 @@ class ProductFlat
'locale' => $locale->code
]);
- if ($parentProductFlat) {
+ if ($parentProductFlat)
$productFlat->parent_id = $parentProductFlat->id;
- }
}
$productFlat->save();
diff --git a/packages/Webkul/Sales/src/Models/Order.php b/packages/Webkul/Sales/src/Models/Order.php
index ccc30912a..b7235a208 100755
--- a/packages/Webkul/Sales/src/Models/Order.php
+++ b/packages/Webkul/Sales/src/Models/Order.php
@@ -171,9 +171,8 @@ class Order extends Model implements OrderContract
return false;
foreach ($this->items as $item) {
- if ($item->canShip()) {
+ if ($item->canShip())
return true;
- }
}
return false;
@@ -188,9 +187,8 @@ class Order extends Model implements OrderContract
return false;
foreach ($this->items as $item) {
- if ($item->canInvoice()) {
+ if ($item->canInvoice())
return true;
- }
}
return false;
@@ -205,9 +203,8 @@ class Order extends Model implements OrderContract
return false;
foreach ($this->items as $item) {
- if ($item->canCancel()) {
+ if ($item->canCancel())
return true;
- }
}
return false;
diff --git a/packages/Webkul/Sales/src/Models/OrderItem.php b/packages/Webkul/Sales/src/Models/OrderItem.php
index a7d540bee..d4997e74c 100755
--- a/packages/Webkul/Sales/src/Models/OrderItem.php
+++ b/packages/Webkul/Sales/src/Models/OrderItem.php
@@ -129,6 +129,14 @@ class OrderItem extends Model implements OrderItemContract
return $this->hasOne(OrderItemProxy::modelClass(), 'parent_id');
}
+ /**
+ * Get the parent item record associated with the order item.
+ */
+ public function parent()
+ {
+ return $this->belongsTo(self::class, 'parent_id');
+ }
+
/**
* Get the children items.
*/
diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
index b83b6dbce..b5bf0b2f2 100755
--- a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
@@ -138,17 +138,21 @@ class InvoiceRepository extends Repository
]);
foreach ($orderItem->children as $childOrderItem) {
- $invoiceItem->child = $this->invoiceItemRepository->create([
+ $finalQty = $childOrderItem->qty_ordered
+ ? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty
+ : $child->qty_ordered;
+
+ $this->invoiceItemRepository->create([
'invoice_id' => $invoice->id,
'order_item_id' => $childOrderItem->id,
'parent_id' => $invoiceItem->id,
'name' => $childOrderItem->name,
'sku' => $childOrderItem->sku,
- 'qty' => $qty,
+ 'qty' => $finalQty,
'price' => $childOrderItem->price,
'base_price' => $childOrderItem->base_price,
- 'total' => $childOrderItem->price * $qty,
- 'base_total' => $childOrderItem->base_price * $qty,
+ 'total' => $childOrderItem->price * $finalQty,
+ 'base_total' => $childOrderItem->base_price * $finalQty,
'tax_amount' => 0,
'base_tax_amount' => 0,
'discount_amount' => 0,
@@ -157,6 +161,8 @@ class InvoiceRepository extends Repository
'product_type' => $childOrderItem->product_type,
'additional' => $childOrderItem->additional,
]);
+
+ $this->orderItemRepository->collectTotals($childOrderItem);
}
$this->orderItemRepository->collectTotals($orderItem);
diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
index 5bedfa4f1..4da9cf23a 100755
--- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
@@ -85,38 +85,34 @@ class OrderItemRepository extends Repository
*/
public function manageInventory($orderItem)
{
- if (! $orderedQuantity = $orderItem->qty_ordered)
- return;
-
- $products = [];
+ $orderItems = [];
if ($orderItem->product->getTypeInstance()->isComposite()) {
foreach ($orderItem->children as $child) {
- if (! $child->product)
- continue;
-
- $products[] = $child->product;
+ $orderItems[] = $child;
}
} else {
- if (! $orderItem->product)
- return;
-
- $products[] = $orderItem->product;
+ $orderItems[] = $orderItem;
}
- foreach ($products as $product) {
- $orderedInventory = $product->ordered_inventories()
- ->where('channel_id', $orderItem->order->channel->id)
- ->first();
+ foreach ($orderItems as $item) {
+ if (! $item->product)
+ continue;
+
+ $orderedInventory = $item->product->ordered_inventories()
+ ->where('channel_id', $orderItem->order->channel->id)
+ ->first();
+
+ $qty = $item->qty_ordered ?: $item->parent->qty_ordered;
if ($orderedInventory) {
$orderedInventory->update([
- 'qty' => $orderedInventory->qty + $orderItem->qty_ordered
+ 'qty' => $orderedInventory->qty + $qty
]);
} else {
- $product->ordered_inventories()->create([
- 'qty' => $orderItem->qty_ordered,
- 'product_id' => $product->id,
+ $item->product->ordered_inventories()->create([
+ 'qty' => $qty,
+ 'product_id' => $item->product_id,
'channel_id' => $orderItem->order->channel->id,
]);
}
@@ -131,19 +127,15 @@ class OrderItemRepository extends Repository
*/
public function returnQtyToProductInventory($orderItem)
{
- if (! $product = $orderItem->product)
- return;
-
- $orderedInventory = $product->ordered_inventories()
+ $orderedInventory = $orderItem->product->ordered_inventories()
->where('channel_id', $orderItem->order->channel->id)
->first();
if (! $orderedInventory)
- return ;
+ return;
- if (($qty = $orderedInventory->qty - $orderItem->qty_to_cancel) < 0) {
+ if (($qty = $orderedInventory->qty - ($orderItem->qty_ordered ? $orderItem->qty_to_cancel : $orderItem->parent->qty_ordered)) < 0)
$qty = 0;
- }
$orderedInventory->update([
'qty' => $qty
diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php
index 7546d8ad7..fcd548dbc 100755
--- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php
@@ -139,12 +139,37 @@ class OrderRepository extends Repository
Event::fire('sales.order.cancel.before', $order);
foreach ($order->items as $item) {
- if ($item->qty_to_cancel) {
- $this->orderItemRepository->returnQtyToProductInventory($item);
+ if (! $item->qty_to_cancel)
+ continue;
- $item->qty_canceled += $item->qty_to_cancel;
+ $orderItems = [];
- $item->save();
+ if ($item->product->getTypeInstance()->isComposite()) {
+ foreach ($item->children as $child) {
+ $orderItems[] = $child;
+ }
+ } else {
+ $orderItems[] = $item;
+ }
+
+ foreach ($orderItems as $orderItem) {
+ if (! $orderItem->product)
+ continue;
+
+ $this->orderItemRepository->returnQtyToProductInventory($orderItem);
+
+ if ($orderItem->qty_ordered) {
+ $orderItem->qty_canceled += $orderItem->qty_to_cancel;
+ $orderItem->save();
+
+ if ($orderItem->parent && $orderItem->parent->qty_ordered) {
+ $orderItem->parent->qty_canceled += $orderItem->parent->qty_to_cancel;
+ $orderItem->parent->save();
+ }
+ } else {
+ $orderItem->parent->qty_canceled += $orderItem->parent->qty_to_cancel;
+ $orderItem->parent->save();
+ }
}
}
@@ -156,7 +181,7 @@ class OrderRepository extends Repository
}
/**
- * @inheritDoc
+ * @return integer
*/
public function generateIncrementId()
{
diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php
index a043079f7..c9a574cb3 100644
--- a/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php
@@ -39,9 +39,8 @@ class ShipmentItemRepository extends Repository
->first();
if ($orderedInventory) {
- if (($orderedQty = $orderedInventory->qty - $data['qty']) < 0) {
+ if (($orderedQty = $orderedInventory->qty - $data['qty']) < 0)
$orderedQty = 0;
- }
$orderedInventory->update([
'qty' => $orderedQty
@@ -59,12 +58,11 @@ class ShipmentItemRepository extends Repository
->where('inventory_source_id', $data['shipment']->inventory_source_id)
->first();
- if (!$inventory)
+ if (! $inventory)
return;
- if (($qty = $inventory->qty - $data['qty']) < 0) {
+ if (($qty = $inventory->qty - $data['qty']) < 0)
$qty = 0;
- }
$inventory->update([
'qty' => $qty
diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
index 956d028c3..32b5cd8e5 100755
--- a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
@@ -115,9 +115,7 @@ class ShipmentRepository extends Repository
'shipment_id' => $shipment->id,
'order_item_id' => $orderItem->id,
'name' => $orderItem->name,
- 'sku' => ($orderItem->type == 'configurable')
- ? $orderItem->child->sku
- : $orderItem->sku,
+ 'sku' => $orderItem->getTypeInstance()->getOrderedItem($orderItem)->sku,
'qty' => $qty,
'weight' => $orderItem->weight * $qty,
'price' => $orderItem->price,
@@ -129,17 +127,32 @@ class ShipmentRepository extends Repository
'additional' => $orderItem->additional,
]);
- $product = ($orderItem->type == 'configurable')
- ? $orderItem->child->product
- : $orderItem->product;
+ if ($orderItem->getTypeInstance()->isComposite()) {
+ foreach ($orderItem->children as $child) {
+ if (! $child->qty_ordered)
+ continue;
- $this->shipmentItemRepository->updateProductInventory([
- 'shipment' => $shipment,
- 'shipmentItem' => $shipmentItem,
- 'product' => $product,
- 'qty' => $qty,
- 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
- ]);
+ $finalQty = ($child->qty_ordered / $orderItem->qty_ordered) * $qty;
+
+ $this->shipmentItemRepository->updateProductInventory([
+ 'shipment' => $shipment,
+ 'shipmentItem' => $shipmentItem,
+ 'product' => $child->product,
+ 'qty' => $finalQty,
+ 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
+ ]);
+
+ $this->orderItemRepository->update(['qty_shipped' => $child->qty_shipped + $finalQty], $child->id);
+ }
+ } else {
+ $this->shipmentItemRepository->updateProductInventory([
+ 'shipment' => $shipment,
+ 'shipmentItem' => $shipmentItem,
+ 'product' => $orderItem->product,
+ 'qty' => $qty,
+ 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
+ ]);
+ }
$this->orderItemRepository->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);
}
diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
index a660ae318..a9409e0b1 100755
--- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
+++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
@@ -947,7 +947,6 @@ section.slider-block {
}
.item-details .item-options {
- font-size: 16px;
margin-bottom: 8px;
}
@@ -4364,4 +4363,13 @@ section.review {
grid-template-columns: 30% 30% 30%;
grid-column-gap: 4%;
}
+}
+
+.item-options {
+ font-size: 14px;
+ font-weight: 200;
+
+ b {
+ font-weight: 500;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
index 186e3e326..213e447bf 100755
--- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
@@ -56,7 +56,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/mini-cart.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/mini-cart.blade.php
index 2e74b9487..fa5847dfa 100755
--- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/mini-cart.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/mini-cart.blade.php
@@ -62,7 +62,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php
index 60ad84bc7..3bfab1c95 100755
--- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php
@@ -115,7 +115,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/orders/view.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/orders/view.blade.php
index b1d5c84c6..5cf178ab6 100755
--- a/packages/Webkul/Shop/src/Resources/views/customers/account/orders/view.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/customers/account/orders/view.blade.php
@@ -75,7 +75,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php
index 3df960b90..d88ee23f1 100755
--- a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php
@@ -44,7 +44,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php
index 5b189b1e8..ebc1a3816 100644
--- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php
@@ -119,7 +119,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php
index 5f7997489..b0ab88403 100644
--- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php
@@ -130,7 +130,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php
index 930cbb124..0dc41a4d1 100755
--- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php
@@ -120,7 +120,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php
index 6a4fa6ae5..8991f2444 100755
--- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php
@@ -121,7 +121,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php
index 3d56766c6..825a39ee1 100755
--- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php
@@ -131,7 +131,7 @@
@foreach ($item->additional['attributes'] as $attribute)
- {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach