PHP Example การดึงข้อมูล Product List [Get method]

$accessToken = '[Access Token]';        
$params = [];
$params['store_id'] = [Store ID];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://queue.bentoweb.com/api/productlist?".http_build_query($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     'Content-Type: application/json',
     'Authorization: Bearer ' . $accessToken
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch));
curl_close ($ch);

ค่าที่ได้รับกลับมา

{ ▼
  +"data": {#2422 ▼
    +"total": 138
    +"product_list": array:10 [▼
      0 => {#2423 ▼
        +"product_id": 46506
        +"store_id": (Store ID)
        +"name": "Zero Item"
        +"description": ""
        +"seo_url": "product-46506"
        +"price": 300
        +"label": ""
        +"weight": 0
        +"override_loyalty": false
        +"loyalty_points": 0
        +"remain_stock": 960
        +"seq": 11
        +"active": false
        +"thumb": "(URL)"
        +"image": "(URL)"
        +"category": array:2 [▶]
        +"product_variant": array:1 [▼
          0 => {#2421 ▼
            +"product_variant_id": 71963
            +"product_id": 46506
            +"name": "ธรรมดา"
            +"sku": "abc-286"
            +"barcode": "BTW0000000071963"
            +"price": 600
            +"has_wholesale": true
            +"wholesale": {#2420 ▶}
            +"override_loyalty": false
            +"loyalty_points": 0
            +"seq": 1
            +"default": true
            +"stock": 995
            +"pre_sold": 12
            +"post_sold": 23
            +"real_stock": 960
            +"customer_group_name": ""
          }
        ]
      }
    ]
  }
  +"status": 1
}

Leave a Reply