• Resolved mmarshall1993

    (@mmarshall1993)


    Hi There,

    I’m writing a custom function where I can scan the order number barcode e.g. CT101 on a packing slip to update it’s status.

    To change any order details I need the order id instead. How do I get the order id from the order number that was generated from this plugin?

    Kind Regards,
    Mark

    • This topic was modified 3 years, 11 months ago by mmarshall1993.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @mmarshall1993,

    You can use below code in the custom function to return $order_id from the custom $order_number

    //$order_number is the Order Number
    		$args    = array(
                'post_type'      => 'shop_order',
                'post_status'    => 'any',
                'meta_query'     => array(
                    array(
                        'key'        => '_order_number',
                        'value'      => $order_number,  //here you pass the Order Number
                        'compare'    => '=',
                    )
                )
            );
            $query   = new WP_Query( $args );
            if ( !empty( $query->posts ) ) {
                $order_id = $query->posts[ 0 ]->ID;
            }
    Thread Starter mmarshall1993

    (@mmarshall1993)

    Many thanks, it works great.

    Thanks for your help.

    Kind Regards,
    Mark

    Plugin Author WebToffee

    (@webtoffee)

    Hi @mmarshall1993,

    That’s good. If you like the plugin and support, please leave a review here.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get Order ID from Order Number’ is closed to new replies.