使用Bigcommerce PHP库我想为特定订单创建新货件。
use Bigcommerce\Api\Resources as Resources;
$shipment = new Resources\Shipment();
$shipment->order_id = 100;
$shipment->order_address_id = 3;
$shipment->items = ['order_product_id' => 4, 'quantity' => 1];
$shipment->create();
它返回:未捕获的客户端错误(400):未提供必填字段'order_product_id'。
Bigcommerce控制台说要传递这样的项目:[{“order_product_id”:3,“数量”:1}]
我已经尝试将JSON对象和stdClass对象传递给items字段,但它们都不适用于我。是否有更有效的方式来创建货件?
答案 0 :(得分:3)
问题在于:
$shipment->items = ['order_product_id' => 4, 'quantity' => 1];
需要采用对象格式:
$shipment->items = [['order_product_id' => 4, 'quantity' => 1]];