Fixed issues #300 & Updated inventory in product grid after order received
This commit is contained in:
parent
5ebe171117
commit
6fba17ea81
|
|
@ -67,7 +67,7 @@ class Order {
|
||||||
$productListener = app(\Webkul\Admin\Listeners\Product::class);
|
$productListener = app(\Webkul\Admin\Listeners\Product::class);
|
||||||
|
|
||||||
foreach ($order->items as $item) {
|
foreach ($order->items as $item) {
|
||||||
$productListener->afterProductCreated($item->product);
|
$productListener->afterOrderRecieved($item->product->id, $item->qty_ordered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +213,20 @@ class Product {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the product quantity when the order is received
|
||||||
|
*
|
||||||
|
* @param $productId
|
||||||
|
* @param $itemQuantity
|
||||||
|
*/
|
||||||
|
public function afterOrderRecieved($productId, $itemQuantity) {
|
||||||
|
$productGrid = $this->productGrid->findOneByField('product_id', $productId);
|
||||||
|
|
||||||
|
$productGrid->update(['quantity' => $productGrid->quantity - $itemQuantity]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually invoke this function when you have created the products by importing or seeding or factory.
|
* Manually invoke this function when you have created the products by importing or seeding or factory.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -639,9 +639,9 @@ class Cart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cart->customer_email = $cart->shipping_address->email;
|
$cart->customer_email = $cart->billing_address->email;
|
||||||
$cart->customer_first_name = $cart->shipping_address->first_name;
|
$cart->customer_first_name = $cart->billing_address->first_name;
|
||||||
$cart->customer_last_name = $cart->shipping_address->last_name;
|
$cart->customer_last_name = $cart->billing_address->last_name;
|
||||||
$cart->save();
|
$cart->save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue