Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a shipment bigcommerce

I am attempting to create a shipment to go along with an order, however the process fail upon creating the order, but returns no error, only crashes the program.

Here are a couple ways that I have tried:

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

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

This block fails without error upon createResource

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

This block fails without error on the first line.

Is my syntax off somewhere, or am I just missing something?

like image 333
Mason G Avatar asked Aug 24 '26 22:08

Mason G


1 Answers

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

like image 95
Saran Avatar answered Aug 26 '26 11:08

Saran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!