2

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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