Есть конструкция для получения информации о заказе, при указании id заказа вручную, все работает. Как получить id заказа не зная его? или получить информацию о заказе без id.
add_action( 'woocommerce_new_order', 'get_order_details_woo', 1, 1 );
function get_order_details_woo ($id, $order )
{
$order_id = $order->get_id();
$order = wc_get_order($order_id);
$item_data = $order->get_data();
// Iterating through each WC_Order_Item_Product objects
foreach ($order->get_items() as $item_key => $item_values) {
## Using WC_Order_Item methods ##
// Item ID is directly accessible from the $item_key in the foreach loop or
$item_id = $item_values->get_id();
## Using WC_Order_Item_Product methods ##
$item_name = $item_values->get_name(); // Name of the product
## Access Order Items data properties (in an array of values) ##
$item_data = $item_values->get_data();
$product_name = $item_data['name'];
$product_id = $item_data['product_id'];
$variation_id = $item_data['variation_id'];
$quantity = $item_data['quantity'];
$tax_class = $item_data['tax_class'];
$line_subtotal = $item_data['subtotal'];
$line_subtotal_tax = $item_data['subtotal_tax'];
$line_total = $item_data['total'];
$line_total_tax = $item_data['total_tax'];
// prepare_arr_items($product_name, $quantity, $line_total, $order_id);
}
}