title: Keep and get order status history with their time stamps in Woocommerce 3
body: <p>I want to save the order status history for all orders on woocommerce. e.g If the order status is changed from pending to processing the previous status along with its timestamp should be saved so that user can view their order status history through this <a href="http://cargow.co.uk/?order_no=983&amp;check=checking" rel="nofollow noreferrer">page</a>. I have done some research but I couldn't find a way to do this.  </p>
  
  <p><a href="https://i.stack.imgur.com/Spj4G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Spj4G.png" alt="Somewhat this is required... Check order status on live site the this image "></a></p>
  
  <p>I would like to hear the suggestions. The order tracking is done using a custom plugin. I am retrieving the order  details using the following $order object</p>
  
  <pre><code>$order = wc_get_order( $order_id );
  </code></pre>
  
  <p>I am retrieving the billing, shipping details, status and products details using this object. It would be somewhat easier for me to maintain and get the order status history using this object. Following is the object data I get from the above method</p>
  
  <pre><code>object(WC_Order)#3738 (14) { ["status_transition":protected]=&gt; bool(false) ["data":protected]=&gt; array(28) { ["parent_id"]=&gt; int(0) ["status"]=&gt; string(10) "processing" ["currency"]=&gt; string(3) "GBP" ["version"]=&gt; string(5) "3.5.0" ["prices_include_tax"]=&gt; bool(false) ["date_created"]=&gt; object(WC_DateTime)#3745 (4) { ["utc_offset":protected]=&gt; int(0) ["date"]=&gt; string(26) "2018-11-01 15:05:40.000000" ["timezone_type"]=&gt; int(1) ["timezone"]=&gt; string(6) "+00:00" } ["date_modified"]=&gt; object(WC_DateTime)#3742 (4) { ["utc_offset":protected]=&gt; int(0) ["date"]=&gt; string(26) "2018-11-01 16:02:14.000000" ["timezone_type"]=&gt; int(1) ["timezone"]=&gt; string(6) "+00:00" } ["discount_total"]=&gt; string(2) "36" ["discount_tax"]=&gt; string(1) "0" ["shipping_total"]=&gt; string(1) "0" ["shipping_tax"]=&gt; string(1) "0" ["cart_tax"]=&gt; string(1) "0" ["total"]=&gt; string(6) "325.30" ["total_tax"]=&gt; string(1) "0" ["customer_id"]=&gt; int(0) ["order_key"]=&gt; string(22) "wc_order_5bdb16e89ce36" ["billing"]=&gt; array(11) { ["first_name"]=&gt; string(6) "Faizan" ["last_name"]=&gt; string(5) "Zahid" ["company"]=&gt; string(4) "Home" ["address_1"]=&gt; string(6) "456789" ["address_2"]=&gt; string(4) "5678" ["city"]=&gt; string(6) "lahore" ["state"]=&gt; string(2) "PB" ["postcode"]=&gt; string(6) "456789" ["country"]=&gt; string(2) "PK" ["email"]=&gt; string(19) "fzahid001@gmail.com" ["phone"]=&gt; string(0) "" } ["shipping"]=&gt; array(9) { ["first_name"]=&gt; string(6) "Tabish" ["last_name"]=&gt; string(5) "Munir" ["company"]=&gt; string(7) "Frizhub" ["address_1"]=&gt; string(8) "34567890" ["address_2"]=&gt; string(7) "4567890" ["city"]=&gt; string(6) "lahore" ["state"]=&gt; string(2) "PB" ["postcode"]=&gt; string(6) "456789" ["country"]=&gt; string(2) "PK" } ["payment_method"]=&gt; string(5) "other" ["payment_method_title"]=&gt; string(5) "other" ["transaction_id"]=&gt; string(0) "" ["customer_ip_address"]=&gt; string(0) "" ["customer_user_agent"]=&gt; string(0) "" ["created_via"]=&gt; string(5) "admin" ["customer_note"]=&gt; string(0) "" ["date_completed"]=&gt; NULL ["date_paid"]=&gt; object(WC_DateTime)#3790 (4) { ["utc_offset":protected]=&gt; int(0) ["date"]=&gt; string(26) "2018-11-01 15:15:33.000000" ["timezone_type"]=&gt; int(1) ["timezone"]=&gt; string(6) "+00:00" } ["cart_hash"]=&gt; string(0) "" } ["items":protected]=&gt; array(0) { } ["items_to_delete":protected]=&gt; array(0) { } ["cache_group":protected]=&gt; string(6) "orders" ["data_store_name":protected]=&gt; string(5) "order" ["object_type":protected]=&gt; string(5) "order" ["id":protected]=&gt; int(983) ["changes":protected]=&gt; array(0) { } ["object_read":protected]=&gt; bool(true) ["extra_data":protected]=&gt; array(0) { } ["default_data":protected]=&gt; array(28) { ["parent_id"]=&gt; int(0) ["status"]=&gt; string(0) "" ["currency"]=&gt; string(0) "" ["version"]=&gt; string(0) "" ["prices_include_tax"]=&gt; bool(false) ["date_created"]=&gt; NULL ["date_modified"]=&gt; NULL ["discount_total"]=&gt; int(0) ["discount_tax"]=&gt; int(0) ["shipping_total"]=&gt; int(0) ["shipping_tax"]=&gt; int(0) ["cart_tax"]=&gt; int(0) ["total"]=&gt; int(0) ["total_tax"]=&gt; int(0) ["customer_id"]=&gt; int(0) ["order_key"]=&gt; string(0) "" ["billing"]=&gt; array(11) { ["first_name"]=&gt; string(0) "" ["last_name"]=&gt; string(0) "" ["company"]=&gt; string(0) "" ["address_1"]=&gt; string(0) "" ["address_2"]=&gt; string(0) "" ["city"]=&gt; string(0) "" ["state"]=&gt; string(0) "" ["postcode"]=&gt; string(0) "" ["country"]=&gt; string(0) "" ["email"]=&gt; string(0) "" ["phone"]=&gt; string(0) "" } ["shipping"]=&gt; array(9) { ["first_name"]=&gt; string(0) "" ["last_name"]=&gt; string(0) "" ["company"]=&gt; string(0) "" ["address_1"]=&gt; string(0) "" ["address_2"]=&gt; string(0) "" ["city"]=&gt; string(0) "" ["state"]=&gt; string(0) "" ["postcode"]=&gt; string(0) "" ["country"]=&gt; string(0) "" } ["payment_method"]=&gt; string(0) "" ["payment_method_title"]=&gt; string(0) "" ["transaction_id"]=&gt; string(0) "" ["customer_ip_address"]=&gt; string(0) "" ["customer_user_agent"]=&gt; string(0) "" ["created_via"]=&gt; string(0) "" ["customer_note"]=&gt; string(0) "" ["date_completed"]=&gt; NULL ["date_paid"]=&gt; NULL ["cart_hash"]=&gt; string(0) "" } ["data_store":protected]=&gt; object(WC_Data_Store)#3734 (4) { ["instance":"WC_Data_Store":private]=&gt; object(WC_Order_Data_Store_CPT)#3804 (3) { ["internal_meta_keys":protected]=&gt; array(78) { [0]=&gt; string(10) "_parent_id" [1]=&gt; string(7) "_status" [2]=&gt; string(9) "_currency" [3]=&gt; string(8) "_version" [4]=&gt; string(19) "_prices_include_tax" [5]=&gt; string(13) "_date_created" [6]=&gt; string(14) "_date_modified" [7]=&gt; string(15) "_discount_total" [8]=&gt; string(13) "_discount_tax" [9]=&gt; string(15) "_shipping_total" [10]=&gt; string(13) "_shipping_tax" [11]=&gt; string(9) "_cart_tax" [12]=&gt; string(6) "_total" [13]=&gt; string(10) "_total_tax" [14]=&gt; string(12) "_customer_id" [15]=&gt; string(10) "_order_key" [16]=&gt; string(8) "_billing" [17]=&gt; string(9) "_shipping" [18]=&gt; string(15) "_payment_method" [19]=&gt; string(21) "_payment_method_title" [20]=&gt; string(15) "_transaction_id" [21]=&gt; string(20) "_customer_ip_address" [22]=&gt; string(20) "_customer_user_agent" [23]=&gt; string(12) "_created_via" [24]=&gt; string(14) "_customer_note" [25]=&gt; string(15) "_date_completed" [26]=&gt; string(10) "_date_paid" [27]=&gt; string(10) "_cart_hash" [28]=&gt; string(14) "_customer_user" [29]=&gt; string(10) "_order_key" [30]=&gt; string(15) "_order_currency" [31]=&gt; string(19) "_billing_first_name" [32]=&gt; string(18) "_billing_last_name" [33]=&gt; string(16) "_billing_company" [34]=&gt; string(18) "_billing_address_1" [35]=&gt; string(18) "_billing_address_2" [36]=&gt; string(13) "_billing_city" [37]=&gt; string(14) "_billing_state" [38]=&gt; string(17) "_billing_postcode" [39]=&gt; string(16) "_billing_country" [40]=&gt; string(14) "_billing_email" [41]=&gt; string(14) "_billing_phone" [42]=&gt; string(20) "_shipping_first_name" [43]=&gt; string(19) "_shipping_last_name" [44]=&gt; string(17) "_shipping_company" [45]=&gt; string(19) "_shipping_address_1" [46]=&gt; string(19) "_shipping_address_2" [47]=&gt; string(14) "_shipping_city" [48]=&gt; string(15) "_shipping_state" [49]=&gt; string(18) "_shipping_postcode" [50]=&gt; string(17) "_shipping_country" [51]=&gt; string(15) "_completed_date" [52]=&gt; string(10) "_paid_date" [53]=&gt; string(10) "_edit_lock" [54]=&gt; string(10) "_edit_last" [55]=&gt; string(14) "_cart_discount" [56]=&gt; string(18) "_cart_discount_tax" [57]=&gt; string(15) "_order_shipping" [58]=&gt; string(19) "_order_shipping_tax" [59]=&gt; string(10) "_order_tax" [60]=&gt; string(12) "_order_total" [61]=&gt; string(15) "_payment_method" [62]=&gt; string(21) "_payment_method_title" [63]=&gt; string(15) "_transaction_id" [64]=&gt; string(20) "_customer_ip_address" [65]=&gt; string(20) "_customer_user_agent" [66]=&gt; string(12) "_created_via" [67]=&gt; string(14) "_order_version" [68]=&gt; string(19) "_prices_include_tax" [69]=&gt; string(15) "_date_completed" [70]=&gt; string(10) "_date_paid" [71]=&gt; string(15) "_payment_tokens" [72]=&gt; string(22) "_billing_address_index" [73]=&gt; string(23) "_shipping_address_index" [74]=&gt; string(15) "_recorded_sales" [75]=&gt; string(29) "_recorded_coupon_usage_counts" [76]=&gt; string(29) "_download_permissions_granted" [77]=&gt; string(20) "_order_stock_reduced" } ["meta_type":protected]=&gt; string(4) "post" ["object_id_field_for_meta":protected]=&gt; string(0) "" } ["stores":"WC_Data_Store":private]=&gt; array(20) { ["coupon"]=&gt; string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=&gt; string(22) "WC_Customer_Data_Store" ["customer-download"]=&gt; string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=&gt; string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=&gt; string(30) "WC_Customer_Data_Store_Session" ["order"]=&gt; string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=&gt; string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=&gt; string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=&gt; string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=&gt; string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=&gt; string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=&gt; string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=&gt; string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=&gt; string(27) "WC_Payment_Token_Data_Store" ["product"]=&gt; string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=&gt; string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=&gt; string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=&gt; string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=&gt; string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=&gt; string(21) "WC_Webhook_Data_Store" } ["current_class_name":"WC_Data_Store":private]=&gt; string(23) "WC_Order_Data_Store_CPT" ["object_type":"WC_Data_Store":private]=&gt; string(5) "order" } ["meta_data":protected]=&gt; array(5) { [0]=&gt; object(WC_Meta_Data)#3792 (2) { ["current_data":protected]=&gt; array(3) { ["id"]=&gt; int(2671) ["key"]=&gt; string(17) "_vc_post_settings" ["value"]=&gt; array(1) { ["vc_grid_id"]=&gt; array(0) { } } } ["data":protected]=&gt; array(3) { ["id"]=&gt; int(2671) ["key"]=&gt; string(17) "_vc_post_settings" ["value"]=&gt; array(1) { ["vc_grid_id"]=&gt; array(0) { } } } } [1]=&gt; object(WC_Meta_Data)#3793 (2) { ["current_data":protected]=&gt; array(3) { ["id"]=&gt; int(2718) ["key"]=&gt; string(14) "slide_template" ["value"]=&gt; string(7) "default" } ["data":protected]=&gt; array(3) { ["id"]=&gt; int(2718) ["key"]=&gt; string(14) "slide_template" ["value"]=&gt; string(7) "default" } } [2]=&gt; object(WC_Meta_Data)#3795 (2) { ["current_data":protected]=&gt; array(3) { ["id"]=&gt; int(2719) ["key"]=&gt; string(19) "_bewpi_invoice_date" ["value"]=&gt; string(19) "2018-11-01 15:08:31" } ["data":protected]=&gt; array(3) { ["id"]=&gt; int(2719) ["key"]=&gt; string(19) "_bewpi_invoice_date" ["value"]=&gt; string(19) "2018-11-01 15:08:31" } } [3]=&gt; object(WC_Meta_Data)#3794 (2) { ["current_data":protected]=&gt; array(3) { ["id"]=&gt; int(2720) ["key"]=&gt; string(21) "_bewpi_invoice_number" ["value"]=&gt; string(3) "983" } ["data":protected]=&gt; array(3) { ["id"]=&gt; int(2720) ["key"]=&gt; string(21) "_bewpi_invoice_number" ["value"]=&gt; string(3) "983" } } [4]=&gt; object(WC_Meta_Data)#3797 (2) { ["current_data":protected]=&gt; array(3) { ["id"]=&gt; int(2721) ["key"]=&gt; string(23) "_bewpi_invoice_pdf_path" ["value"]=&gt; string(19) "2018/00983-2018.pdf" } ["data":protected]=&gt; array(3) { ["id"]=&gt; int(2721) ["key"]=&gt; string(23) "_bewpi_invoice_pdf_path" ["value"]=&gt; string(19) "2018/00983-2018.pdf" } } } }
  </code></pre>