Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

RESTAPI Question to Retrieve Order Details

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-03-2015, 09:18 AM
 
Al Ponte Al Ponte is offline
 

Newbie
  
Join Date: Apr 2015
Posts: 4
 

Default 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?
__________________
Al Ponte
Reply With Quote
  #2  
Old 05-04-2015, 12:27 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!

Last edited by qualiteam : 05-04-2015 at 10:48 PM.
Reply With Quote
  #3  
Old 05-04-2015, 03:15 PM
 
Al Ponte Al Ponte is offline
 

Newbie
  
Join Date: Apr 2015
Posts: 4
 

Default 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?
__________________
Al Ponte
Reply With Quote
  #4  
Old 05-05-2015, 02:33 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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?
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #5  
Old 05-05-2015, 06:30 AM
 
Al Ponte Al Ponte is offline
 

Newbie
  
Join Date: Apr 2015
Posts: 4
 

Default Re: RESTAPI Question to Retrieve Order Details

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.
Attached Thumbnails
Click image for larger version

Name:	cust-address-image.png
Views:	185
Size:	142.1 KB
ID:	4126  
__________________
Al Ponte
Reply With Quote
  #6  
Old 05-06-2015, 02:37 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #7  
Old 05-06-2015, 07:44 AM
 
Al Ponte Al Ponte is offline
 

Newbie
  
Join Date: Apr 2015
Posts: 4
 

Default 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?
__________________
Al Ponte
Reply With Quote

The following user thanks Al Ponte for this useful post:
tony_sologubov (05-08-2015)
  #8  
Old 05-08-2015, 02:23 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #9  
Old 05-31-2015, 04:30 AM
 
BenJamir BenJamir is offline
 

Newbie
  
Join Date: May 2015
Posts: 10
 

Default 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.
__________________
Ben
Reply With Quote
  #10  
Old 06-03-2015, 03:43 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020