1 回答
TA贡献1895条经验 获得超3个赞
对于一个简单的循环,您的解决方案看起来有点混乱和过于复杂。看起来您是在重新声明 items 值,而不是添加到 items 数组。我认为这应该更接近你所追求的:
$order_details = [
"email" => $order->get_billing_email(),
"phone" => $order->get_billing_phone(),
"company" => $order->get_billing_company(),
"firstName" => $order->get_billing_first_name(),
];
$all_items = [];
foreach( $order->get_items() as $item_key => $item ){
$this_product = $item->get_product();
$all_items[] = [
"description" => $item->get_name(),
"orderLineId"=>0,
"priceType"=>"string",
"productCode"=>$this_product->get_sku(),
"productDescription" =>"string",
"quantity" => $item->get_quantity(),
"unitPrice"=> $this_product->get_price()
];
}
$message = [
"order" => $order_details,
"items" => $all_items,
];
- 1 回答
- 0 关注
- 77 浏览
添加回答
举报