| @@ 11-28 (lines=18) @@ | ||
| 8 | use Eccube\Service\PurchaseFlow\PurchaseContext; |
|
| 9 | use Eccube\Service\PurchaseFlow\ValidatableItemProcessor; |
|
| 10 | ||
| 11 | class DeletedProductValidator extends ValidatableItemProcessor |
|
| 12 | { |
|
| 13 | protected function validate(ItemInterface $item, PurchaseContext $context) |
|
| 14 | { |
|
| 15 | $ProductClass = $item->getProductClass(); |
|
| 16 | $Product = $ProductClass->getProduct(); |
|
| 17 | if ($Product->getDelFlg()) { |
|
| 18 | throw new ItemValidateException('cart.product.delete'); |
|
| 19 | } |
|
| 20 | } |
|
| 21 | ||
| 22 | protected function handle(ItemInterface $item, PurchaseContext $context) |
|
| 23 | { |
|
| 24 | if ($item instanceof CartItem) { |
|
| 25 | $item->setQuantity(0); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 11-30 (lines=20) @@ | ||
| 8 | use Eccube\Service\PurchaseFlow\PurchaseContext; |
|
| 9 | use Eccube\Service\PurchaseFlow\ValidatableItemProcessor; |
|
| 10 | ||
| 11 | class DisplayStatusValidator extends ValidatableItemProcessor |
|
| 12 | { |
|
| 13 | protected function validate(ItemInterface $item, PurchaseContext $context) |
|
| 14 | { |
|
| 15 | if (!$item->isProduct()) { |
|
| 16 | return; |
|
| 17 | } |
|
| 18 | $ProductClass = $item->getProductClass(); |
|
| 19 | if (!$ProductClass->isEnable()) { |
|
| 20 | throw new ItemValidateException('cart.product.not.status'); |
|
| 21 | } |
|
| 22 | } |
|
| 23 | ||
| 24 | protected function handle(ItemInterface $item, PurchaseContext $context) |
|
| 25 | { |
|
| 26 | if ($item instanceof CartItem) { |
|
| 27 | $item->setQuantity(0); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | } |
|
| 31 | ||