Question

I need a little help. I am working with big commerce API and I am stuck at a point. Here is something that I want to achieve. I have retrieved the order details and then the products from it. Now I want to somehow get the options that are attached to the specific product.

This is what my code looks like...

$minutes_to_go_back = 165;                              
$time = time() - ($minutes_to_go_back * 60);//calculating time
$date =  date(DateTime::RFC2822,$time);//getting date in required format
$filter = array('min_date_created' => $date);//query filter
$orders = Bigcommerce::getOrders($filter);//received all the orders in last '$minutes_to_go_back' minutes
$order_products = $orders[$i]->products();//getting products of orders..one by one traversing through orders
print_r($order_products);

This is what it prints.

enter image description here

You will see there is an option that says Gift Message. I want to get its value. Can someone please guide me on how to do that?

Thanks in Advance for any help. Ahmad

Was it helpful?

Solution

After working for a couple days with the BigCommerce team, I was finally able to get this issue resolved for my own use, so I thought the solution would be useful here for fellow Google travellers:

include_once './vendor/autoload.php';
use Bigcommerce\Api\Client as Bigcommerce;

Bigcommerce::configure(array(
    'store_url' => 'YOUR_URL',
    'username'  => 'YOUR_USERNAME',
    'api_key'   => 'YOUR_API_KEY'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);


$ping = Bigcommerce::getTime();
if ($ping) echo $ping->format('H:i:s'); 

$orderID = "78165";

$options = Bigcommerce::getCollection('/orders/' . $orderID . '/products/', 'OrderProduct');
print_r($options);  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top