PHP - WooCommerce - get_order()

Moobs

Regular Member
Jan 30, 2015
270
23
I'm trying to create a function that will retrieve an order by its ID. For some reason I can't get the WC global function "get_order" to work. I'm passing a valid order id to the function and trying to print it out to verify that it's working. The function has been placed in my functions.php file.

Code:
function getWC_order_details($id){     global $woocommerce;

    $order = get_order( $id );

    print "<pre>";
    print_r($order);
    print "</pre>"; }

Test Output:

Code:
<php getWC_order_details(466); ?>

Note: I have tested echoing other data out of the function without a problem.

Any help would be greatly appreciated.
 
Have you tried (in functions.php):

Code:
function getWC_order_details($id){
	global $woocommerce;
	
	$order = new WC_Order( $id );


	print "<pre>";
	print_r($order);
	print "</pre>";
}
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock