Getting orderID and total amount in Woocommerce? why so difficult?

I added this function in my themes functions.php but it just not working.. any idea what i do wrong?

function woocommerce_thankyou_fun( $order_id ) 
{
    $order = new WC_Order( $order_id );  
    // $ttotal = $order->get_order_total();
    //echo trim( str_replace( '#', '', $order->get_order_number() ) );
    //$order_id  = absint( $wp->query_vars['order-received'] );
    //$order = new WC_Order($GLOBALS['post']->ID);
    echo  $order;    
}

add_shortcode('Woocommerce-Thankyou', 'woocommerce_thankyou_fun');

Related posts

1 comment

  1. Use this code to see all datamember of order object.

    function woocommerce_thankyou_fun( $order_id ) 
    {
      $order = new WC_Order( $order_id );  
    
      echo  "<pre>";   
      print_r( $order);
      echo  "</pre>";   
    
     die();
    
    }
    
    add_shortcode('woocommerce-thankyou', 'woocommerce_thankyou_fun',20,1);
    

Comments are closed.