• Resolved rasidrsd

    (@rasidrsd)


    Hey guys,

    i want to access the Order Number (Without the Prefix, just the Numbers that increases every time) from my functions.php file.

    I have a function that is called with a do_action from WooCommerce.
    In this Function i need to get the Order Number.

    Does anyone know how to do this?
    $order->$order_number; does not work
    var_dump($order_number); is NULL.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Basically to get WooCommerce order number, you should call $order->get_order_number() function, however this will return full order number (with prefix etc.). You can then remove prefix by calling something like str_replace( 'yourprefix', '', $order->get_order_number() ).

    In standard WooCommerce order numbers are order ids, so you can also access it by simply $order->id. This will return original order number, i.e. without Booster’s numbering and without prefix, suffix etc.

    If you want to access Booster given order number without prefix etc., you can get it by accessing order meta, like this: get_post_meta( $order->id, '_wcj_order_number', true ).

    Please let me know if this helped.

    And if you like Booster, please leave us a rating.

    Best regards,
    Tom

    • This reply was modified 8 years, 2 months ago by Algoritmika.
    • This reply was modified 8 years, 2 months ago by Algoritmika.
    • This reply was modified 8 years, 2 months ago by Algoritmika.
    Thread Starter rasidrsd

    (@rasidrsd)

    Wow, thank you for this quick and perfect reply.
    Can you give me a source where I can find all the functions related to $order? (Like get_order_number() or other parameters like billing_adress, etc.)?

    Sure. You can find all functions here – https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html

    Best regards,
    Tom

    Thread Starter rasidrsd

    (@rasidrsd)

    So I pruchased the Booster Plus Plugin and now I need to get the Order Number with the “Width”.
    Like Order Number: 1
    Order Width: 3
    –> 001
    Need to get ‘001’.
    I couldn’t find the width in Get_post_meta($order->id);

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