how to create a dynamic array? I need to set the dynamic value of product id and qty and passing into the items array.
$itemarray = [];
foreach ($ItemCollection as $item) {
$productId = $item['order_item_id'];
$qty = $item['qty'];
}
$orderData = [
'email' => $customerEmail, //buyer email id
'shipping_address' => [
'firstname' => $firstname, //address Details
'lastname' => $lastname,
'street' => $address,
'city' => $city,
'country_id' => $countryid,
'region' => $region,
'regionId' => $regionid,
'postcode' => $postcode,
'telephone' => $telephone
],
'items'=> [
//array of product which order you want to create
['product_id'=>'1','qty'=>1],
['product_id'=>'2','qty'=>2]
]
]
;