mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Added new events adding, updating, removing.
This commit is contained in:
14
src/Cart.php
14
src/Cart.php
@@ -167,10 +167,14 @@ class Cart
|
||||
$content->put($item->rowId, $item);
|
||||
|
||||
if ($dispatchEvent) {
|
||||
$this->events->dispatch('cart.added', $item);
|
||||
$this->events->dispatch('cart.adding', $item);
|
||||
}
|
||||
|
||||
$this->session->put($this->instance, $content);
|
||||
|
||||
if ($dispatchEvent) {
|
||||
$this->events->dispatch('cart.added', $item);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
@@ -222,9 +226,11 @@ class Cart
|
||||
}
|
||||
}
|
||||
|
||||
$this->events->dispatch('cart.updated', $cartItem);
|
||||
$this->events->dispatch('cart.updating', $cartItem);
|
||||
|
||||
$this->session->put($this->instance, $content);
|
||||
|
||||
$this->events->dispatch('cart.updated', $cartItem);
|
||||
|
||||
return $cartItem;
|
||||
}
|
||||
@@ -244,9 +250,11 @@ class Cart
|
||||
|
||||
$content->pull($cartItem->rowId);
|
||||
|
||||
$this->events->dispatch('cart.removed', $cartItem);
|
||||
$this->events->dispatch('cart.removing', $cartItem);
|
||||
|
||||
$this->session->put($this->instance, $content);
|
||||
|
||||
$this->events->dispatch('cart.removed', $cartItem);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user