wc_get_order
Main function for returning orders, uses the WC_Order_Factory class.
Description
(WC_Order|WC_Refund) wc_get_order( (bool) $the_order = false );
Returns (WC_Order|WC_Refund)
Parameters (1)
- 0. $the_order — Optional. (bool) =>
false
- Post object or post ID of the order.
Usage
if ( !function_exists( 'wc_get_order' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php'; } // Post object or post ID of the order. $the_order = false; // NOTICE! Understand what this does before running. $result = wc_get_order($the_order);
Defined (1)
The function is defined in the following location(s).
- /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).', woocommerce ), '2.5' );
- return false;
- }
- return WC()->order_factory->get_order( $the_order );
- }