/** * {@inheritdoc} */ public function isStockSufficient(StockableInterface $stockable, $quantity) { if ($stockable instanceof SoftDeletableInterface && $stockable->isDeleted()) { return false; } if ($this->backorders || $stockable->isAvailableOnDemand()) { return true; } return $quantity <= $stockable->getOnHand() - $stockable->getOnHold(); }
/** * {@inheritdoc} */ public function release(StockableInterface $stockable, $quantity) { if ($quantity < 0) { throw new \InvalidArgumentException('Quantity of units must be greater than 0.'); } $this->eventDispatcher->dispatch(SyliusStockableEvents::PRE_RELEASE, new GenericEvent($stockable)); $stockable->setOnHold($stockable->getOnHold() - $quantity); $this->eventDispatcher->dispatch(SyliusStockableEvents::POST_RELEASE, new GenericEvent($stockable)); }