3

我正在尝试创建与订单一起发货的货物,但是该过程在创建订单时失败,但没有返回错误,只会使程序崩溃。

以下是我尝试过的几种方法:

$shipment = array(
    'tracking_number' => $TrackingNumber,
    'order_address_id' => $orderAddressId,
    'items' => $itemArray
);

Bigcommerce::createResource('/orders/'.$order->id.'/shipments', $shipment);

此块在 createResource 时失败且没有错误

$shipment = new Bigcommerce\Api\Resources\Shipments();
$shipment->tracking_number = $TrackingNumber;
$shipment->order_address_id = $orderAddressId;
$shipment->items = $itemArray;
$shipment->create();

这个块在第一行没有错误就失败了。

我的语法是不是在某个地方,或者我只是错过了什么?

4

1 回答 1

1

You cannot create subresources like that. You need to extend the Resource model. Look at this sample code from the Bigcommerce PHP lib -

https://github.com/bigcommerce/bigcommerce-api-php/blob/master/src/Bigcommerce/Api/Resources/OrderProduct.php

It defines orders/products. You need to do something similar for orders/shipments

于 2013-09-09T20:03:31.683 回答