Author Topic: Get order products  (Read 490 times)

m.davide82

  • Jr. Member
  • **
  • Posts: 166
Get order products
« on: November 28, 2018, 00:54:09 am »
Hello,

I need to get the order products, but I'm losing with arrays! ;(

I have this code that works:

Code: [Select]

           $P=array();
foreach($products as $product)
{
$P[] = array(
"sku"=> $product->order_item_sku,
"name"=>  $product->order_item_name,
"qty"=>  $product->product_quantity,
"price"=>   $product->product_item_price,
"total"=> $product->product_final_price,
);
}


I need to put the results in a json like that:

Code: [Select]
        'articles' => [
          array(
            'sku' => $product->order_item_sku,
            'name' => $product->order_item_name,
            'qty' =>  $product->product_quantity,
            'price' => $product->product_item_price,
            'total' => $product->product_final_price,
          )
        ],

Probably it's very simply, but I'm going crazy! ;)
Can someone help me, please?


Thanks a lot!