News:

Support the VirtueMart project and become a member

Main Menu

Get order products

Started by m.davide82, November 28, 2018, 00:54:09 AM

Previous topic - Next topic

m.davide82

Hello,

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

I have this code that works:


           $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:


        '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!