Magento 2 Get Coupon Code Programmatically File
try $order = $this->orderRepository->get($orderId); return $order->getCouponCode(); catch (\Exception $e) return null;
$this->orderRepository = $orderRepository; magento 2 get coupon code programmatically
public function __construct( CartRepositoryInterface $quoteRepository, CustomerSession $customerSession, CheckoutSession $checkoutSession ) $this->quoteRepository = $quoteRepository; $this->customerSession = $customerSession; $this->checkoutSession = $checkoutSession; try $order = $this->
private GetCouponCodeService $couponService; private JsonFactory $resultJsonFactory; catch (\Exception $e) return null