From 75f4d9925c58b0da1f9c2fbc6632a46ea698b9bd Mon Sep 17 00:00:00 2001 From: SteffenMahler <57138594+SteffenMahler@users.noreply.github.com> Date: Thu, 20 Feb 2020 13:58:10 +0100 Subject: [PATCH] Fire event if customer wants to "buy now" If a customer wants to buy a single product directly, the CartController add() method fires an event. The same event has to be fired via api request. In this case it's store() method. --- .../Webkul/API/Http/Controllers/Shop/CartController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/API/Http/Controllers/Shop/CartController.php b/packages/Webkul/API/Http/Controllers/Shop/CartController.php index 8e76ef534..a1281faef 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CartController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CartController.php @@ -98,6 +98,10 @@ class CartController extends Controller */ public function store($id) { + if (request()->get('is_buy_now')) { + Event::dispatch('shop.item.buy-now', $id); + } + Event::dispatch('checkout.cart.item.add.before', $id); $result = Cart::addProduct($id, request()->except('_token')); @@ -228,4 +232,4 @@ class CartController extends Controller 'data' => $cart ? new CartResource($cart) : null ]); } -} \ No newline at end of file +}