Conditions | 5 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | protected function validate(ItemInterface $item, PurchaseContext $context) |
||
16 | { |
||
17 | if (!$item->isProduct()) { |
||
18 | return; |
||
19 | } |
||
20 | if ($item->getProductClass()->getStockUnlimited()) { |
||
21 | return; |
||
22 | } |
||
23 | $stock = $item->getProductClass()->getStock(); |
||
24 | $quantity = $item->getQuantity(); |
||
25 | if ($stock == 0) { |
||
26 | throw new ItemValidateException('cart.zero.stock', ['%product%' => $item->getProductClass()->getProduct()->getName()]); |
||
27 | } |
||
28 | if ($stock < $quantity) { |
||
29 | throw new ItemValidateException('cart.over.stock', ['%product%' => $item->getProductClass()->getProduct()->getName()]); |
||
30 | } |
||
31 | } |
||
32 | |||
39 |