* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\SpecificPrice\CommandHandler; use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\DeleteSpecificPriceByCartProductCommand; use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\CommandHandler\DeleteSpecificPriceByCartProductHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceException; use PrestaShopException; use SpecificPrice; @trigger_error( sprintf( '%s is deprecated since version 8.0.0 and will be removed in the next major version.', DeleteSpecificPriceByCartProductHandler::class ), E_USER_DEPRECATED ); /** * @deprecated since 8.0.0 and will be removed in the next major version. */ final class DeleteSpecificPriceByCartProductHandler implements DeleteSpecificPriceByCartProductHandlerInterface { /** * @param DeleteSpecificPriceByCartProductCommand $command * * @throws SpecificPriceException */ public function handle(DeleteSpecificPriceByCartProductCommand $command): void { $productAttributeId = $command->getProductAttributeId() ?? false; $cartIdValue = $command->getCartId()->getValue(); $productIdValue = $command->getProductId()->getValue(); try { if (false === SpecificPrice::deleteByIdCart($cartIdValue, $productIdValue, $productAttributeId)) { throw new SpecificPriceException(sprintf('Failed to delete specific price for cart #%s product #%s', $cartIdValue, $productIdValue)); } } catch (PrestaShopException $e) { throw new SpecificPriceException(sprintf('An error occurred when trying to delete specific price for cart #%s product #%s', $cartIdValue, $productIdValue)); } } }