Get meta data after payment in woocommerce

I am using this to create a new field in my woocommerce billing form

add_filter('woocommerce_checkout_fields', array(__CLASS__,'custom_woocommerce_billing_fields'));
function custom_woocommerce_billing_fields($fields)
{
    $fields['billing']['billing_mobile'] = array(
        'label' => __('Mobile Phone Number', 'woocommerce'), // Add custom field label
        'placeholder' => _x('Mobile Phone Number', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => true, // if field is required or not
        'clear' => false, // add clear or not
        'type' => 'text', // add field type
        'class' => array('my-css')   // add class name
    );

and also i use this code to do action after payment:

add_action( 'woocommerce_payment_complete', array(__CLASS__,'create_invoice_for_wc_order'));
function create_invoice_for_wc_order( $order_id ) { 
    // get order details data...
    $order = wc_get_order( $order_id );

}

the question is how can i get that mobile number which user enter before payment in my "create_invoice_for_wc_order" function?

Solutions

After $order = wc_get_order( $order_id ); try:

$order_data = $order->get_data();
print_r($order_data);

There should be your billing_mobile field

Similar questions

Payment Woocommerce Checkout Payment Targeting
I am trying to target the element of "div#payment.woocommerce-checkout-payment". My purpose is to change the link coloration. I have tried many variations of targeting and it just doesn't seem to want to change. Am I targeting incorrectly. I have tired it without the div, with the id, with the div. Sample Product: https://www.changedwards.com/produ...
Manually send WooCommerce order from pending payment to payment gateway
I have a renewal based site. I'm using WooCommerce with WooCommerce Subscription on my site. I attached a custom function to the filter wcs_renewal_order_created. The filter is applied after a renewal order is created. The custom function gave a fatal error and the renewal process got halted Current situation: The renewal orders are stuck on "Pendi...
Woocommerce - Display payment method "payment on delivery" only for Admin Users
Please, how can i set on Woocommerce the payment method "payment on delivery" only for Admin Profile User? Is that possible? This means, the payment method "payment on delivery" will be available on the checkout page only for users logged on WP and with admin profile. Gratitude for the help!
How to set custom checkout payment fields from custom WooCommerce Payment gateway
I created the plugins and added custom fields on the checkout page like payment_mode & transaction id. Here the payment mode & transaction is custom filed, It gets the data from users and adds the database table. In the above coding, $order->update_status - Its working fine. But $wcorder->add_meta_data is not working. It does not show...
Disable WooCommerce checkout payment for specific user meta data
My customer wants to enable for some specific customers to pay afterwards via invoice. So i've added an extra field in the user profiles, where he can select yes/no. This field works fine and saves properly. Depending on the choice: no = default webshop behavior and customer needs to pay direct. yes = customer can order items without paying, he'll ...
woocommerce: how to add data obtained from remote server to an item after payment completed?
We're selling digital-only products. Each sold item need a new univoque product key, where key depends on the item itself User buys an item on a store After paying, but before woocommerce send email to the user, woocommerce ask our server the token sending items details. The product key of each item is saved into item details Email will be sent to ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .