I need to get the following information after checkout:
- order ID
- order date
- customer name (F/L)
- customer phone
- customer email
Which will be put into the session array and then stored in a seperate database. Currently in my theme's functions.php file I have the following:
//get completed order data:
add_action( 'woocommerce_order_status_completed', 'my_function' );
function my_function($order_id) {
$order = new WC_Order( $order_id );
$_SESSION['kiosk_data']['order_number'] = $order->[what would I use here?];
$_SESSION['kiosk_data']['order_date'] = $order->[what would I use here?];
$_SESSION['kiosk_data']['f_name'] = $order->[what would I use here?];
$_SESSION['kiosk_data']['l_name'] = $order->[what would I use here?];
$_SESSION['kiosk_data']['phone'] = $order->[what would I use here?];
$_SESSION['kiosk_data']['email'] = $order->[what would I use here?];
//for testing:
$kioskDataFile = './testFile.txt';
$kioskData = "kioskID: ".$_SESSION['kiosk_data']['kioskID']."
";
$kioskData.= "order date: ";
$kioskData.= $order->order_date;
$kioskData.= "
";
$kioskData.= "order ID: ";
$kioskData.= $order->id;
$kioskData.= "
";
$kioskData.= "order key: ";
$kioskData.= $order->order_key;
$kioskData.= "
";
$kioskData.= "first name: ";
$kioskData.= $order->billing_first_name;
$kioskData.= "
";
$kioskData.= "last name: ";
$kioskData.= $order->billing_last_name;
$kioskData.= "
";
$kioskData.= "phone: ";
$kioskData.= $order->billing_phone;
$kioskData.= "
";
$kioskData.= "email: ";
$kioskData.= $order->billing_email;
$kioskData.= "
";
file_put_contents($kioskDataFile, $kioskData, FILE_APPEND);
}
Being very new to WP/woocommerce I'm really not sure how to go about capturing this data (tried several google searches to no avail).