public function getCurrentQuoteCouponCode(): ?string
// For logged-in customers if ($this->customerSession->isLoggedIn()) $customerId = $this->customerSession->getCustomerId(); $quote = $this->quoteRepository->getActiveForCustomer($customerId); else // For guest customers $quote = $this->checkoutSession->getQuote(); magento 2 get coupon code programmatically
use Magento\Quote\Api\CartRepositoryInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Framework\Exception\NoSuchEntityException; public function getCurrentQuoteCouponCode():