Woocommerce 2.5.5 get billing email from order instance

I am trying to get the billing email of an order in woocommerce v2.5.5
However its giving me this error:

Call to undefined method WC_Order::get_billing_email()

Here is my order object : print_r($order)

enter image description here

My Code

        $order_id = $order->get_order_number();
        $customer_email = $order->get_billing_email();
        $shipping_country = $order->get_shipping_country();
        $order_items = $order->get_items();

Both get_billing_email and get_shipping_country isn’t working.

Condition : I can’t upgrade the plugin as the site is really old and i’m 100% sure it’ll cost me another 50 to 60 hours to fix everything. Just need a quick fix.

2 Answers
2

In WC version 2.5, get and set functions are not available.
The parameters you want are public. So, you can directly access them:

    $customer_email = $order->billing_email;
    $shipping_country = $order->shipping_country;

And so on.

Please check the keys before using them.

Leave a Comment