* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; use PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveCartRuleFromCartCommand; use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\RemoveCartRuleFromCartHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; /** * @internal */ final class RemoveCartRuleFromCartHandler extends AbstractCartHandler implements RemoveCartRuleFromCartHandlerInterface { /** * {@inheritdoc} */ public function handle(RemoveCartRuleFromCartCommand $command) { $cart = $this->getCart($command->getCartId()); if (!$cart->removeCartRule($command->getCartRuleId()->getValue())) { throw new CartException(sprintf('Failed to remove cart rule with id "%d" from cart', $command->getCartRuleId()->getValue())); } } }