for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Eccube\Service\PurchaseFlow\Processor;
use Eccube\Entity\ItemInterface;
use Eccube\Service\PurchaseFlow\ItemValidateException;
use Eccube\Service\PurchaseFlow\ValidatableItemProcessor;
use Eccube\Service\PurchaseFlow\PurchaseContext;
/**
* 販売制限数チェック.
*/
class SaleLimitValidator extends ValidatableItemProcessor
{
protected function validate(ItemInterface $item, PurchaseContext $context)
if (!$item->isProduct()) {
return;
}
$limit = $item->getProductClass()->getSaleLimit();
if (is_null($limit)) {
$quantity = $item->getQuantity();
if ($limit < $quantity) {
throw new ItemValidateException('cart.over.sale_limit', ['%product%' => $item->getProductClass()->getProduct()->getName()]);
protected function handle(ItemInterface $item, PurchaseContext $context)
$item->setQuantity($limit);