dispatcher = $dispatcher; } public function postInsert(ConnectionInterface $con = null) { if ($this->dispatcher) { $cartEvent = new CartEvent($this->getCart()); $this->dispatcher->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent); } } public function postUpdate(ConnectionInterface $con = null) { if ($this->dispatcher) { $cartEvent = new CartEvent($this->getCart()); $this->dispatcher->dispatch(TheliaEvents::CART_MODIFYITEM, $cartEvent); } } /** * @param $value * @return $this */ public function addQuantity($value) { $currentQuantity = $this->getQuantity(); $newQuantity = $currentQuantity + $value; if($newQuantity <= 0) { $newQuantity = $currentQuantity; } if(ConfigQuery::read("verifyStock", 1) == 1) { $productSaleElements = $this->getProductSaleElements(); if($productSaleElements->getQuantity() < $newQuantity) { $newQuantity = $currentQuantity; } } $this->setQuantity($newQuantity); return $this; } }