Get Product Options From Big Commerce - bigcommerce

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.
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

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

Related

How to get the org_id from a webhook?

When a Webhook is triggered, is there a way to get the org_id from which it was fired? (Aside from climbing up the triggered item)
The only solution I found so far is:
PodioItem::get($item_id); to get the space_id
PodioSpace::get($space_id); to get the full
PodioOrganization::get_for_url($attributes = array()); I get the org_id.
See the "Bundling responses using fields parameter" section at the very bottom of https://developers.podio.com/index/api on how you can use the fields query parameter to include more data. There's even an example that goes almost all the way for you (it walks up to the space level, but you can just tack the org onto it):
/item/{item_id}?fields=app.view(full).fields(space.view(full))
For podio-php you can do:
$item = PodioItem::get($item_id, array('fields' => "app.view(full).fields(space.view(full))"));
Use PodioItem::filter instead of PodioItem::get, I'm pretty sure that you'll have the expected results, so try this:
$item = PodioItem::filter($item_id, array('filters' => "app.view(full).fields(space.view(full))"));
Hope it helps!

Get a products from bigcommerce store based on date?

i would like to get some products in my Bigcommerce store based on date using api. So i have followed the following api code like this. But no luck
$filter = array('date_created' => 'Sat, 25 Jan 2014 16:43:15 +0000');//query filter
$products = Bigcommerce::getProducts($filter);
But in the same way following one is working good.
$filter = array('sku' => 'CST-120');//query filter
$products = Bigcommerce::getProducts($filter);
So please any help me how can i change the date variable would be better

How to get charges(transactions) details in Stripe based on date range

I wanted to get a list of charges(Transactions) based on date range I specify, ie all transactions between my specified Start date and End date.
But in CHARGES API, I can not see any Start date nor End Date arguments.
How can I get this?
Had a chat with Stripe staffs through online chat, and found that there is a way to get list of charges based on date range.
Stripe Charges API actually has some argument that are not yet listed in their documentation.
Arguments like created[lte] and created[gte] with Unix timestamp can be used, just like Events API call.
EG: https://api.stripe.com/v1/charges?created[gte]=1362171974&created[lte]=1362517574
Try this one. It's working for me
$pcharges = Charge::all(
array(
'limit' => 100,
'created' => array(
'gte' => strtotime('-15 day'),
'lte' => strtotime('-1 day')
)
)
);
This will return last 15 days data excluding today's transaction. You can set your custom date range as per your requirement.
Here's a Ruby based hack
Stripe.api_key = ENV['STRIPE_SECRET']
stripe_charges = []
first_charge = Stripe::Charge.all(limit: 1).data[0].id
charge_index = first_charge
*a lot of*.times do
new_charges = Stripe::Charge.all(limit: 100, starting_after: charge_index).data
stripe_charges << new_charges
charge_index = new_charges.last.id
stripe_charges.flatten!
end
Was looking in to it today and here is what i found
https://stripe.com/docs/api/curl#list_charges
curl https://api.stripe.com/v1/charges?limit=3 \
-u sk_test_BQokikJOvBiI2HlWgH4olfQ2:
This is stripes curl example there are more examples on their website.
-James Harrington
In case anyone is using Ruby on Rails and is looking for a solution to list out all refunds that's been created after a Unix timestamp, using the created.gte syntax, here's a working example for me that I got from Stripe Support.
Stripe::Refund.list({limit: 100, created: {gte: 1614045880}})
You can change that Unix timestamp to fit your situation.
Resources: Stripe API Reference, List all refunds and Stripe Support
To get particular date data code is like
$mydata= \Stripe\Charge::all(array('limit'=>50,'starting_after'=>null ,"created" => array("gt" => strtotime("2020-02-17"),"lt" => strtotime("2020-02-19"))));
print_r($mydata);
It will give you data of 2020-02-18 with limit 50, If you want more record add last charge id in starting_after parameter

Getting the string representation from CDbCriteria

Is there any way to the get the string representation of the query from CDbCriteria? For testing and debugging purposes.
You can use logging and profiling configuring your main.php like this:
'components'=>array(
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CWebLogRoute',
'categories'=>'system.db.CDbCommand',
'showInFireBug'=>true,
),
),
),
'db'=>array(
'enableProfiling'=>true,
'enableParamLogging'=>true,
),
),
I spend a lot amount of time for finding the answer to this question, so thought of sharing it with you guys. Hope this saves your precious time.
As mentioned by Jon above: CDbCriteria does not aggregate enough information to construct the full query, you have to use the model class information also on which you will put the query constraints.
As the example given in Yii docs for CDbCriteria; this is how basically you use it-
$criteria=new CDbCriteria();
$criteria->compare('status',Post::STATUS_ACTIVE);
$criteria->addInCondition('id',array(1,2,3,4,5,6));
$posts = Post::model()->findAll($criteria);
Here Post is the name of the model on which you execute the query condition.
So if you want to get the text representation of the query written in CDbCriteria, you have to involve the model information also i.e. Post.
This is how you can do it -
$model = new Post();
$query = $model->getCommandBuilder()->createFindCommand($model->getTableSchema(), $criteria)->getText();
When you print the value in $query variable it prints the raw query.
Hope this helps.

Amazon API -- Can I search Category ALL - Other than DVD etc?

I Am trying to build play with API code from Amazon -- I am a noob at this --
I have created a product search using the simple lookup code, and have gone though and set the search field form a form submission works fine, how ever I don't want to set a category Like I am currently below to say DVD, BABY MUSIC, I wish to set to ALL is this possible?
include("amazon_api_class.php");
$obj = new AmazonProductAPI(); -- I have edited this and added ALL as a category in here
try
{
$result = $obj->searchProducts($query,
AmazonProductAPI::BABY, -- I can change this to DVD or MUSIC and it works but if i set to ALL i get errors?
"TITLE"); - tryed changing this to KEYWORD doesnt work!
}
catch(Exception $e)
Any Help Would Be nice.
Thanks
Carl
OK --- updated -- ANd I belive I have to use KEYWORD when USING ALL so I have added this in
case "KEYWORD" : $parameters = array("Operation" => "ItemSearch",
"Title" => $search,
"SearchIndex" => $category,
"ResponseGroup" => "Small",
"MerchantId" => "All",
"Condition"=>"New",
'Keywords' => $searchTerm);
Warning: Invalid argument supplied for foreach() in /data/ADMINwhere2shoponline/www/include/amazon.php on line 23
still get this error?
carl
Carl,
You should be able to use ALL as the search parameter, but you need to make sure that the number of ItemPage you are requesting is not more than 5 or it will return an error. All other categories allow up to 10, but ALL is limited to 5.
Check that and see if you yet your problem resolved.