Get ordernumber on the event sales_order_payment_pay

I’m trying to get my order number on the event sales_order_payment_pay

But somehow I got nothing .. maybe you can help me ?
Here is the sample of my code in my Observer.php

public function functioninobserver($observer) {
    $orderid = $observer->getEvent()->getInvoice()->getIncrementId();

First of all it returns nothing and I think Incrementid is not the same as orderthe number …

One thought on “Get ordernumber on the event sales_order_payment_pay”

  1. The invoice isn’t the same as the order, you can get the order in a slightly roundabout way…

    $orderId = $observer->getPayment()->getOrder()->getId();
    $orderNumber = $observer->getPayment()->getOrder()->getIncrementId();

    Just to clarify; The order ID is used internally in the database. The order number is what’s displayed on screen and looks like #100000123.

Leave a Reply

Your email address will not be published. Required fields are marked *