Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Create Order #2

Closed
graygilmore opened this issue Jan 30, 2013 · 2 comments
Closed

Unable to Create Order #2

graygilmore opened this issue Jan 30, 2013 · 2 comments

Comments

@graygilmore
Copy link

All other classes work perfect (listing products, company info, etc), but when I try to create an order I get a "FetchApp Not Found" error.

Everything is being included properly (since listing products and other calls work), it's just creating orders, so I must be doing something wrong.

I've tried all sorts of combinations in the XML that I'm sending, the example provided below is simply my latest effort.

Here's my code:

require 'fetchapp/FetchApp.php';
$fetch_app = new FetchApp( 'https://myname.fetchapp.com', 'myname', 'mytoken' );

$new_order = '<?xml version="1.0" encoding="UTF-8"?>
                      <order>
                          <email>email@email.com</email>
                          <order_items type="array">
                              <order_item>
                                  <sku>mysku</sku>
                              </order_item>
                          </order_items>
                      </order>';
$create_order = $fetch_app->orders( 'create', $new_order );
@jasontwong
Copy link
Owner

Gary,

The issue is that you're passing a string as a parameter. Because of the magic method builder, if the parameter is a string, it thinks it's an additional API endpoint. If you want to pass post data it should be a SimpleXMLElement and if you want to pass query parameters it should be an array. I suggest changing your code as follows:

$create_order = $fetch_app->orders( 'create', simplexml_load_string( $new_order ) );

@graygilmore
Copy link
Author

Thanks, Jason, that worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants