• Resolved biiissen

    (@biiissen)


    Hi there,

    I’d like to fetch a Woocommerce order based on the order_number.
    As a work around I could fetch the original Woocommerce order_id based on the order_number and then fetch the order, can that be done?

    I was searching the forum, but it seems nobody wanted to do this prior to me, or my keywords were really bad.
    Thanks in advance for your help. It’s much appreciated.

    Kind regards,
    Laurent

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @biiissen,

    Thanks for reaching out.

    You may use this code to fetch order object using Order number.

    Thread Starter biiissen

    (@biiissen)

    Hello @webtoffeesupport,

    thank you for your reply.
    I found another work around, but I might need you’re snippet in the future.
    So thanks a lot for your help!

    Kind regards,
    Laurent

    Hi Team, I was trying the approach given in the above code, but its judt returning the last order can you please help me on this (note: my order number will be a text eg:P121)

    following is a code snippet

    $ordernid = sanitize_text_field($_POST[‘orderID’]);
    $args = array(
    ‘limit’ =>1,
    array(
    ‘key’ => ‘_order_number’,
    ‘value’ => $ordernid,
    ‘compare’ => ‘=’
    )
    );
    $orders = wc_get_orders($args);
    $order = !empty($orders) && isset($orders[0]) ? $orders[0] : null;

    Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @arunmozhivarman,

    We have updated the code provided in the previous link. Kindly try this approach.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Fetch order based on order_number’ is closed to new replies.