I created an observer with event checkout_onepage_controller_success_action. I need applied coupon code on checkout onepage success in magento 2. I have to send order coupon code to third party with Curl. Do you know, how we can retrieve coupon code used for the order on order success page?

Here is my observer code:

$orderIds = $observer->getEvent()->getOrderIds();
$lastorderId = $orderIds[0];
$order = $this->orderFactory->load($lastorderId);
// echo $order->getQuoteId(); // show quote ID
// echo $order->getDiscountAmount(); // show discount amount

/* Here I need applied Coupon Code */

2 Answers 2


For getting the coupon code of an order, you should use


  • Quick Solution. Thanks @amit , its working for me. Commented Apr 30, 2018 at 6:47
  • Hi @amit,this works but how to get that amount that was applied for this coupon code in the order page.
    – anil
    Commented Feb 7, 2019 at 9:52

You can use function:


In sales_order table, there is field coupon_code for applied coupon code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.