X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   RESTAPI Question to Retrieve Order Details (https://forum.x-cart.com/showthread.php?t=71964)

Al Ponte 05-03-2015 09:18 AM

RESTAPI Question to Retrieve Order Details
 
I have read all of the documentation about the RESTAPI and I do NOT use Guzzle.

I cannot figure out how to fetch the order billing address information, specifically the First Name, Last Name and Company.

I am able to get the Order itself and the users email and Profile...

Can anyone point me in the right direction?

tony_sologubov 05-04-2015 12:27 AM

Re: RESTAPI Question to Retrieve Order Details
 
@Al Ponte,

You can pull order info by calling this URL:
Code:

admin.php?target=RESTAPI&_key=rest-api-key&_path=order/ORDERID&_schema=complex

ORDERID part should be replaced by actual order ID.

Al Ponte 05-04-2015 03:15 PM

Re: RESTAPI Question to Retrieve Order Details
 
Tony,

I had figured that out just before reading this but unfortunately, Company is not included in the returned schema. Upon further inspection, it seems Company is not included in the complex schema definition.

Also, how can I use RESTAPI to add a note to an order?

tony_sologubov 05-05-2015 02:33 AM

Re: RESTAPI Question to Retrieve Order Details
 
Quote:

Originally Posted by Al Ponte
Tony,

I had figured that out just before reading this but unfortunately, Company is not included in the returned schema. Upon further inspection, it seems Company is not included in the complex schema definition.

Also, how can I use RESTAPI to add a note to an order?


Do you mean Company as a custom field in customer profile? Or do you mean some other Company field?

Al Ponte 05-05-2015 06:30 AM

Re: RESTAPI Question to Retrieve Order Details
 
1 Attachment(s)
Tony,

Thanks for your quick response again! I added the field to the "Address Fields" tab of Cart & Checkout settings. I attached a screen shot of it.

tony_sologubov 05-06-2015 02:37 AM

Re: RESTAPI Question to Retrieve Order Details
 
Thanks for clarification.

Unfortunately, there is no straight-forward way of pulling Company field.

You can achieve this by multiple queries:
1) Make a query to "order/ORDERID" and see the profile_id field in response
2) Make a query to "profile/PROFILE_ID" and see the value in addresses > address_id field in response
3) Finally make a query to "address/ADDRESS_ID" end-point and get the results.

Alternatively, you can extend the REST API module and include the Company info into complex schema.

Al Ponte 05-06-2015 07:44 AM

Re: RESTAPI Question to Retrieve Order Details
 
Tony,

Thanks! That solution will work just fine - I am actually authoring a page that will allow our customers to sign-up with our service after purchasing a subscription.

Is there any way to add an order event note to an order using REST?

tony_sologubov 05-08-2015 02:23 AM

Re: RESTAPI Question to Retrieve Order Details
 
Quote:

Originally Posted by Al Ponte
Is there any way to add an order event note to an order using REST?


Yes, sure. For that you need to put data for \XLite\Model\OrderHistoryEvents model.
So, you will have to make a POST request to url with _path=orderhistoryevents/0

BenJamir 05-31-2015 04:30 AM

Re: RESTAPI Question to Retrieve Order Details
 
Does anyone know how to get the individual item attributes that were selected on the order for each item.

Using &_path=order, you can easily get all the items that were on the order but not the item attributes.

Any help would be greatly appreciated.

tony_sologubov 06-03-2015 03:43 AM

Re: RESTAPI Question to Retrieve Order Details
 
Hello @Ben,

Here is the code example (using Guzzle) that will do a trick for you:

PHP Code:

$result $client->get('order/10')->json();

foreach (
$result['items'] as $item) {
    
$item $client->get('orderitem/' $item['item_id'])->json();
    foreach (
$item['attributeValues'] as $attribute_value) {
        echo 
'name: ' $attribute_value['name'] . ' value: ' $attribute_value['value'];
    }



Please, let me know if it helps.

Tony


All times are GMT -8. The time now is 08:12 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.