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

  1. if ( !function_exists( 'wc_get_order' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php'; 
  3.  
  4. // Post object or post ID of the order. 
  5. $the_order = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_order($the_order); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-order-functions.php  
  1. function wc_get_order( $the_order = false ) { 
  2. if ( ! did_action( 'woocommerce_after_register_post_type' ) ) { 
  3. 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' ); 
  4. return false; 
  5. return WC()->order_factory->get_order( $the_order );