| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 9 |
| 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 | |||
| 21 | $limit = $item->getProductClass()->getSaleLimit(); |
||
| 22 | if (is_null($limit)) { |
||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | $quantity = $item->getQuantity(); |
||
| 27 | if ($limit < $quantity) { |
||
| 28 | throw new ItemValidateException('cart.over.sale_limit', ['%product%' => $item->getProductClass()->getProduct()->getName()]); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 38 |