1

Using the Bigcommerce PHP library I want to create a new shipment for a specific order.

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();

It is returning: Uncaught Client Error (400): The required field 'order_product_id' was not supplied.

The Bigcommerce console says to pass items like this: [{"order_product_id":3,"quantity":1}]

I have tried passing JSON objects and stdClass objects to the items field, but none of them are working for me. Is there a more efficient way to create a shipment?

4

1 回答 1

3

问题是:

$shipment->items = ['order_product_id' => 4, 'quantity' => 1];

需要为对象格式:

$shipment->items = [['order_product_id' => 4, 'quantity' => 1]];
于 2013-04-19T17:12:25.020 回答