PHP version 7.1
Zencart Version v1.5.7c
Im trying to implement a invoice api from a third partner, all my test code is working good but i dont know how to extrat the ordered products.
I need to have an array with all the data
Code:
$data = array(
'Client[ID]' => $clientDenumire, (static content provided by api developer)
'Client[HASH]' => '7250110', (static content provided by api developer)
'Content[0][Name]' => 'Product 1 name',
'Content[0][Price]' => '10',
'Content[0][qty]' => '5');
'Content[1][Name]' => 'Product 2 name',
'Content[1][Price]' => '12',
'Content[1][qty]' => '3');
'Content[2][Name]' => 'Delivery',
'Content[2][Price]' => '5',
'Content[2][qty]' => '1');
);
I need to extract the ordered products in same array, also the delivery method that user selected
My try :
PHP Code:
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
$products= [
'Content['.$i.'][name]' => $order->products[$i]['name'],
'Content['.$i.'][qty]' => $order->products[$i]['qty'],
'Content['.$i.'][price]' => $order->products[$i]['price'],
];
}
But i dont know how to get close the loop and to extract informations in same array, also to combine it with my static informations
Code:
'Client[ID]' => $clientDenumire, (static content provided by api developer)
'Client[HASH]' => '7250110', (static content provided by api developer)
I also dont know how to extract my delivery method in same array and for each position to count Content[0], Content[1], Content[2] etc.
Bookmarks