10 use \Magento\Quote\Api\CouponManagementInterface;
45 return $quote->getCouponCode();
55 if (!
$quote->getItemsCount()) {
56 throw new NoSuchEntityException(
__(
'The "%1" Cart doesn\'t contain products.',
$cartId));
58 if (!
$quote->getStoreId()) {
59 throw new NoSuchEntityException(
__(
'Cart isn\'t assigned to correct store'));
61 $quote->getShippingAddress()->setCollectShippingRates(
true);
65 $this->quoteRepository->save(
$quote->collectTotals());
66 }
catch (\Exception $e) {
67 throw new CouldNotSaveException(
68 __(
"The coupon code couldn't be applied. Verify the coupon code and try again.")
72 throw new NoSuchEntityException(
__(
"The coupon code isn't valid. Verify the code and try again."));
84 if (!
$quote->getItemsCount()) {
85 throw new NoSuchEntityException(
__(
'The "%1" Cart doesn\'t contain products.',
$cartId));
87 $quote->getShippingAddress()->setCollectShippingRates(
true);
90 $this->quoteRepository->save(
$quote->collectTotals());
91 }
catch (\Exception $e) {
92 throw new CouldNotDeleteException(
93 __(
"The coupon code couldn't be deleted. Verify the coupon code and try again.")
96 if (
$quote->getCouponCode() !=
'') {
97 throw new CouldNotDeleteException(
98 __(
"The coupon code couldn't be deleted. Verify the coupon code and try again.")
__construct(\Magento\Quote\Api\CartRepositoryInterface $quoteRepository)