I am writing json response for woocommerce website for new mobile app. I am totally new to json,php,woocommerce.
From lot of searching I got this API working.this
I am getting response like this when I use this line
$data = $client->products->get('', array('filter[limit]' => '500'));
stdClass Object
(
[products] => Array
(
[0] => stdClass Object
(
[title] => Malai tikka roll
[id] => 2580
[created_at] => 2017-05-22T08:13:56Z
[updated_at] => 2017-05-22T08:14:38Z
[type] => simple
[status] => publish
[downloadable] =>
[virtual] =>
[permalink] => http://localhost/fooddemo/product/malai-tikka-roll/
[sku] =>
[price] => 75.00
[regular_price] => 75.00
[sale_price] =>
Now I want to do is change some fields and send json response through $response object to my android app.
I tried doing this but it gives me error
$response["Title"] = $data["title"];
Undefined index: title in C:\xampp\htdocs\demoservice\productlist.php on line 15
Sample code
<?php
require_once( 'lib/woocommerce-api.php' );
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 30,
'ssl_verify' => false,
);
$response = array("error" => FALSE);
try{
require_once( 'key.php' );
$data = $client->products->get('', array('filter[limit]' => '500'));
//echo json_encode($response);
$response["Title"] = $data["title"];
}catch ( WC_API_Client_Exception $e ) {
require_once( 'catch.php' );
}