wc_get_order( mixed $the_order = false )
Main function for returning orders, uses the WC_Order_Factory class.
Description #Description
Parameters #Parameters
- $the_order
-
(Optional) Post object or post ID of the order.
Default value: false
Return #Return
(bool|WC_Order|WC_Order_Refund)
Source #Source
File: includes/wc-order-functions.php
function wc_get_order( $the_order = false ) { if ( ! did_action( 'woocommerce_after_register_post_type' ) ) { wc_doing_it_wrong( __FUNCTION__, 'wc_get_order should not be called before post types are registered (woocommerce_after_register_post_type action)', '2.5' ); return false; } return WC()->order_factory->get_order( $the_order ); }
Changelog #Changelog
Version | Description |
---|---|
2.2 | Introduced. |
Related #Related
Uses #Uses
Uses | Description |
---|---|
woocommerce.php: WC() |
Returns the main instance of WC. |
includes/wc-deprecated-functions.php: wc_doing_it_wrong() |
Wrapper for _doing_it_wrong(). |
Used By #Used By
Used By | Description |
---|---|
includes/class-wc-ajax.php: WC_AJAX::maybe_add_order_item() |
Add order item via AJAX. This is refactored for better unit testing. |
includes/data-stores/class-wc-order-data-store-cpt.php: WC_Order_Data_Store_CPT::compile_orders() |
Compile order response and set caches as needed for order ids. |
packages/woocommerce-admin/src/API/Reports/Customers/DataStore.php: DataStore::sync_order_customer() |
Sync customers data after an order was updated. |
packages/woocommerce-admin/src/API/Reports/Customers/DataStore.php: DataStore::get_last_order() |
Retrieve the last order made by a customer. |
packages/woocommerce-blocks/src/StoreApi/Routes/Checkout.php: Checkout::create_or_update_draft_order() |
Create or update a draft order based on the cart. |
packages/woocommerce-blocks/src/StoreApi/Routes/Checkout.php: Checkout::get_route_post_response() |
Update and process an order. |
includes/class-wc-order-item.php: WC_Order_Item::get_order() |
Get parent order object. |
includes/emails/class-wc-email-new-order.php: WC_Email_New_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-customer-completed-order.php: WC_Email_Customer_Completed_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-cancelled-order.php: WC_Email_Cancelled_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-customer-invoice.php: WC_Email_Customer_Invoice::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-failed-order.php: WC_Email_Failed_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-customer-note.php: WC_Email_Customer_Note::trigger() |
Trigger. |
includes/emails/class-wc-email-customer-on-hold-order.php: WC_Email_Customer_On_Hold_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-customer-processing-order.php: WC_Email_Customer_Processing_Order::trigger() |
Trigger the sending of this email. |
includes/emails/class-wc-email-customer-refunded-order.php: WC_Email_Customer_Refunded_Order::trigger() |
Trigger. |
includes/admin/wc-admin-functions.php: wc_save_order_items() |
Save order items. Uses the CRUD. |
includes/admin/list-tables/class-wc-admin-list-table-orders.php: WC_Admin_List_Table_Orders::handle_bulk_actions() |
Handle bulk actions. |
includes/admin/list-tables/class-wc-admin-list-table-orders.php: WC_Admin_List_Table_Orders::prepare_row_data() |
Pre-fetch any data for the row each column has access to it. the_order global is there for bw compat. |
includes/admin/class-wc-admin-assets.php: WC_Admin_Assets::admin_scripts() |
Enqueue scripts. |
includes/admin/meta-boxes/class-wc-meta-box-order-items.php: WC_Meta_Box_Order_Items::output() |
Output the metabox. |
includes/admin/meta-boxes/class-wc-meta-box-order-actions.php: WC_Meta_Box_Order_Actions::output() |
Output the metabox. |
includes/admin/meta-boxes/class-wc-meta-box-order-actions.php: WC_Meta_Box_Order_Actions::save() |
Save meta box data. |
includes/admin/meta-boxes/class-wc-meta-box-order-data.php: WC_Meta_Box_Order_Data::output() |
Output the metabox. |
includes/admin/meta-boxes/class-wc-meta-box-order-data.php: WC_Meta_Box_Order_Data::save() |
Save meta box data. |
includes/admin/reports/class-wc-report-downloads.php: WC_Report_Downloads::output_report() |
Output the report. |
includes/admin/reports/class-wc-report-downloads.php: WC_Report_Downloads::column_default() |
Get column value. |
includes/admin/reports/class-wc-report-taxes-by-date.php: WC_Report_Taxes_By_Date::get_main_chart() |
Get the main chart. |
includes/class-wc-payment-tokens.php: WC_Payment_Tokens::get_order_tokens() |
Returns an array of payment token objects associated with the passed order ID. |
includes/gateways/bacs/class-wc-gateway-bacs.php: WC_Gateway_BACS::bank_details() |
Get bank details and place into a list format. |
includes/gateways/bacs/class-wc-gateway-bacs.php: WC_Gateway_BACS::process_payment() |
Process the payment and return the result. |
includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php: WC_Gateway_Paypal_Response::get_paypal_order() |
Get the order from the PayPal ‘Custom’ variable. |
includes/gateways/paypal/class-wc-gateway-paypal.php: WC_Gateway_Paypal::process_refund() |
Process a refund if supported. |
includes/gateways/paypal/class-wc-gateway-paypal.php: WC_Gateway_Paypal::capture_payment() |
Capture payment when the order is changed from on-hold to complete or processing |
includes/gateways/paypal/class-wc-gateway-paypal.php: WC_Gateway_Paypal::process_payment() |
Process the payment and return the result. |
includes/gateways/cod/class-wc-gateway-cod.php: WC_Gateway_COD::process_payment() |
Process the payment and return the result. |
includes/gateways/cod/class-wc-gateway-cod.php: WC_Gateway_COD::is_available() |
Check If The Gateway Is Available For Use. |
includes/gateways/cheque/class-wc-gateway-cheque.php: WC_Gateway_Cheque::process_payment() |
Process the payment and return the result. |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::get_order_refund() |
Get an order refund for the given order ID and ID |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::create_order_refund() |
Create a new order refund for the given order |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::create_order_note() |
Create a new order note for the given order |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::edit_order_note() |
Edit the order note |
includes/legacy/api/class-wc-rest-legacy-orders-controller.php: WC_REST_Legacy_Orders_Controller::prepare_item_for_response() |
Prepare a single order output for response. |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::edit_order() |
Edit an order |
includes/legacy/api/v2/class-wc-api-orders.php: WC_API_Orders::get_order() |
Get the order for the given ID |
includes/class-wc-ajax.php: WC_AJAX::delete_refund() |
Delete a refund. |
includes/class-wc-ajax.php: WC_AJAX::refund_line_items() |
Handle a refund via the edit order screen. |
includes/class-wc-ajax.php: WC_AJAX::calc_line_taxes() |
Calc line tax. |
includes/class-wc-ajax.php: WC_AJAX::save_order_items() |
Save order items via ajax. |
includes/class-wc-ajax.php: WC_AJAX::load_order_items() |
Load order items via ajax. |
includes/class-wc-ajax.php: WC_AJAX::add_order_note() |
Add order note via ajax. |
includes/class-wc-ajax.php: WC_AJAX::add_coupon_discount() |
Add order discount via ajax. |
includes/class-wc-ajax.php: WC_AJAX::remove_order_coupon() |
Remove coupon from an order via ajax. |
includes/class-wc-ajax.php: WC_AJAX::remove_order_item() |
Remove an order item. |
includes/class-wc-ajax.php: WC_AJAX::remove_order_tax() |
Remove an order tax. |
includes/class-wc-ajax.php: WC_AJAX::add_order_fee() |
Add order fee via ajax. |
includes/class-wc-ajax.php: WC_AJAX::add_order_shipping() |
Add order shipping cost via ajax. |
includes/class-wc-ajax.php: WC_AJAX::add_order_tax() |
Add order tax column via ajax. |
includes/class-wc-ajax.php: WC_AJAX::grant_access_to_download() |
Grant download permissions via ajax function. |
includes/class-wc-ajax.php: WC_AJAX::mark_order_status() |
Mark an order with a status. |
includes/class-wc-ajax.php: WC_AJAX::get_order_details() |
Get order details. |
includes/class-wc-cart-session.php: WC_Cart_Session::populate_cart_from_order() |
Get a cart from an order, if user has permission. |
includes/data-stores/class-wc-customer-data-store.php: WC_Customer_Data_Store::get_last_order() |
Gets the customers last order. |
includes/class-wc-post-data.php: WC_Post_Data::before_delete_order() |
Before deleting an order, do some cleanup. |
includes/class-wc-form-handler.php: WC_Form_Handler::cancel_order() |
Cancel a pending order. |
includes/class-wc-form-handler.php: WC_Form_Handler::pay_action() |
Process the pay form. |
includes/class-wc-emails.php: WC_Emails::backorder() |
Backorder notification email. |
includes/class-wc-emails.php: WC_Emails::customer_invoice() |
Prepare and send the customer invoice email on demand. |
includes/wc-cart-functions.php: wc_clear_cart_after_payment() |
Clear cart after payment. |
includes/tracks/events/class-wc-orders-tracking.php: WC_Orders_Tracking::track_order_action() |
Track order actions taken. |
includes/tracks/events/class-wc-orders-tracking.php: WC_Orders_Tracking::track_order_status_change() |
Send a Tracks event when an order status is changed. |
includes/tracks/events/class-wc-orders-tracking.php: WC_Orders_Tracking::track_created_date_change() |
Send a Tracks event when an order date is changed. |
includes/wc-stock-functions.php: wc_increase_stock_levels() |
Increase stock levels for items within an order. |
includes/wc-stock-functions.php: wc_reserve_stock_for_order() |
Hold stock for an order. |
includes/wc-stock-functions.php: wc_release_stock_for_order() |
Release held stock for an order. |
includes/wc-stock-functions.php: wc_maybe_reduce_stock_levels() |
When a payment is complete, we can reduce stock levels for items within an order. |
includes/wc-stock-functions.php: wc_maybe_increase_stock_levels() |
When a payment is cancelled, restore stock. |
includes/wc-stock-functions.php: wc_reduce_stock_levels() |
Reduce stock levels for items within an order, if stock has not already been reduced for the items. |
includes/wc-user-functions.php: wc_get_customer_available_downloads() |
Get customer available downloads. |
includes/wc-user-functions.php: wc_customer_has_capability() |
Checks if a user has a certain capability. |
includes/wc-user-functions.php: wc_update_new_customer_past_orders() |
Get past orders (by email) and update them. |
includes/wc-user-functions.php: wc_paying_customer() |
Order payment completed – This is a paying customer. |
includes/class-wc-download-handler.php: WC_Download_Handler::download_product() |
Check if we need to download a file and check validity. |
includes/class-wc-download-handler.php: WC_Download_Handler::check_order_is_valid() |
Check if an order is valid for downloading from. |
includes/abstracts/abstract-wc-order.php: WC_Abstract_Order::set_parent_id() |
Set parent order ID. |
includes/abstracts/abstract-wc-payment-gateway.php: WC_Payment_Gateway::get_order_total() |
Get the order total in checkout and pay_for_order. |
includes/class-wc-checkout.php: WC_Checkout::process_checkout() |
Process the checkout after the confirm order button is pressed. |
includes/class-wc-checkout.php: WC_Checkout::process_order_without_payment() |
Process an order that doesn’t require payment. |
includes/class-wc-checkout.php: WC_Checkout::create_order() |
Create an order. Error codes: 520 – Cannot insert order into the database. |
includes/class-wc-query.php: WC_Query::get_endpoint_title() |
Get page title for an endpoint. |
includes/wc-order-functions.php: wc_create_order_note() |
Create an order note. |
includes/wc-order-functions.php: wc_get_payment_gateway_by_order() |
Get payment gateway class by order data. |
includes/wc-order-functions.php: wc_order_fully_refunded() |
When refunding an order, create a refund line item if the partial refunds do not match order total. |
includes/wc-order-functions.php: wc_update_total_sales_counts() |
Update total sales amount for each product within a paid order. |
includes/wc-order-functions.php: wc_update_coupon_usage_counts() |
Update used coupon amount for each coupon within an order. |
includes/wc-order-functions.php: wc_cancel_unpaid_orders() |
Cancel all unpaid orders after held duration to prevent stock lock for those products. |
includes/wc-order-functions.php: wc_downloadable_product_permissions() |
Order Status completed – give downloadable product access to customer. |
includes/wc-order-functions.php: wc_delete_shop_order_transients() |
Clear all transients cache for order data. |
includes/wc-order-functions.php: wc_create_refund() |
Create a new order refund programmatically. |
includes/wc-account-functions.php: wc_get_account_orders_actions() |
Get account orders actions. |
includes/shortcodes/class-wc-shortcode-order-tracking.php: WC_Shortcode_Order_Tracking::output() |
Output the shortcode. |
includes/shortcodes/class-wc-shortcode-checkout.php: WC_Shortcode_Checkout::output() |
Output the shortcode. |
includes/shortcodes/class-wc-shortcode-checkout.php: WC_Shortcode_Checkout::order_pay() |
Show the pay page. |
includes/shortcodes/class-wc-shortcode-checkout.php: WC_Shortcode_Checkout::order_received() |
Show the thanks page. |
includes/shortcodes/class-wc-shortcode-my-account.php: WC_Shortcode_My_Account::view_order() |
View order page. |
packages/woocommerce-admin/src/Schedulers/OrdersScheduler.php: OrdersScheduler::import() |
Imports a single order or refund to update lookup tables for. |
packages/woocommerce-admin/src/Features/ShippingLabelBannerDisplayRules.php: ShippingLabelBannerDisplayRules::order_has_shippable_products() |
Checks if there’s a shippable product in the current order. |
packages/woocommerce-admin/src/Features/ShippingLabelBanner.php: ShippingLabelBanner::add_meta_boxes() |
Add metabox to order page. |
packages/woocommerce-admin/src/API/Reports/Controller.php: Controller::get_order_number() |
Get the order number for an order. If no filter is present for |
packages/woocommerce-admin/src/API/Reports/Orders/Stats/DataStore.php: DataStore::sync_order() |
Add order information to the lookup table when orders are created or modified. |
packages/woocommerce-admin/src/API/Reports/Orders/Stats/DataStore.php: DataStore::update() |
Update the database with stats data. |
packages/woocommerce-admin/src/API/Reports/Orders/Stats/DataStore.php: DataStore::delete_order() |
Deletes the order stats when an order is deleted. |
packages/woocommerce-admin/src/API/Reports/Taxes/DataStore.php: DataStore::sync_order_taxes() |
Create or update an entry in the wc_order_tax_lookup table for an order. |
packages/woocommerce-admin/src/API/Reports/Products/DataStore.php: DataStore::sync_order_products() |
Create or update an entry in the wc_admin_order_product_lookup table for an order. |
packages/woocommerce-admin/src/API/Reports/Coupons/DataStore.php: DataStore::sync_order_coupons() |
Create or update an an entry in the wc_order_coupon_lookup table for an order. |
packages/woocommerce-admin/src/Overrides/OrderRefund.php: OrderRefund::get_report_customer_id() |
Get the customer ID of the parent order used for reports in the customer lookup table. |
includes/rest-api/Controllers/Version3/class-wc-rest-order-notes-controller.php: WC_REST_Order_Notes_Controller::create_item() |
Create a single order note. |
includes/rest-api/Controllers/Version3/class-wc-rest-order-refunds-controller.php: WC_REST_Order_Refunds_Controller::prepare_object_for_database() |
Prepares one object for create or update operation. |
includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php: WC_REST_Orders_V1_Controller::prepare_item_for_response() |
Prepare a single order output for response. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php: WC_REST_Order_Refunds_V1_Controller::prepare_item_for_response() |
Prepare a single order refund output for response. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::get_item_permissions_check() |
Check if a given request has access to read a order note. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::delete_item_permissions_check() |
Check if a given request has access delete a order note. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::get_items() |
Get order notes from an order. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::create_item() |
Create a single order note. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::get_item() |
Get a single order note. |
includes/rest-api/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php: WC_REST_Order_Notes_V1_Controller::delete_item() |
Delete a single order note. |
includes/rest-api/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php: WC_REST_Network_Orders_V2_Controller::network_orders() |
Get a collection of orders from the requested blog id |
includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php: WC_REST_Order_Refunds_V2_Controller::prepare_object_for_database() |
Prepares one object for create or update operation. |
includes/rest-api/Controllers/Version2/class-wc-rest-order-notes-v2-controller.php: WC_REST_Order_Notes_V2_Controller::get_items() |
Get order notes from an order. |
includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php: WC_REST_Order_Refunds_V2_Controller::get_object() |
Get object. |
includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php: WC_REST_Order_Refunds_V2_Controller::prepare_object_for_response() |
Prepare a single order output for response. |
includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php: WC_REST_Orders_V2_Controller::get_object() |
Get object. Return false if object is not of required type. |