/** * Buy some buyable products * * @param Vendable $product * @param int $qte * @param int $discount * @return Cart */ public function buy(Sellable $product, $qte, $discount = 0) { $discount = abs((int) $discount); if ($discount > 100) { $discount = 100; } $this->getStorage()->set($product->getName(), $qte * ($product->getPrice() - $product->getPrice() * $discount / 100)); return $this; }