Мне нужно сделать один foreach внутри другого foreach, чтобы я мог получить различную информацию о заказе из woocommerce.
Мой текущий код извлекает всю необходимую мне информацию. хотя мне нужно, чтобы собраться вместе:
foreach ($orders as $order_id) {
$order = wc_get_order($order_id);
$orders[] = [
"id_encomenda" => $order_id,
"morada_envio" => $order->get_formatted_shipping_address(),
"morada_faturacao" => $order->get_formatted_billing_address(),
"email_cliente" => $order->get_billing_email(),
"contacto" => $order->get_billing_phone(),
"metodo_pagamento" => $order->get_payment_method_title(),
"total_encomenda" => $order->get_formatted_order_total(),
"data_pagamento" => $order->get_date_paid(),
"nota_cliente" => $order->get_customer_note(),
"data_encomenda" => $order->get_date_created(),
];
foreach ($order->get_items() as $item_id => $item_data) {
$product = $item_data->get_product();
$produtosEncomenda[] = [
"referencia" => $product->get_sku(),
"nome_produto" => $product->get_name(),
"quantidade" => $item_data->get_quantity(),
];
}