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.
This commit is contained in:
SteffenMahler 2020-02-20 13:58:10 +01:00 committed by GitHub
parent d8bd2cb31e
commit 75f4d9925c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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
]);
}
}
}