Difference between revisions of "API::Order::generate"
(→Parameters) |
(→Returns) |
||
Line 35: | Line 35: | ||
===Returns=== | ===Returns=== | ||
− | Nothing | + | Nothing. If no exception was thrown, then success. |
===Exceptions=== | ===Exceptions=== |
Latest revision as of 14:17, 3 June 2009
Places an order through our website. This method should only be used by resellers that have set up an appropriate reseller account with the Art of Problem Solving. This method is only available to API applications that have order placement privileges.
Contents
[hide]Calling
$api->order->generate($item_list, $name, $address1, $address2,
$city, $state, $zip, $country,
$email, $phone = , $shipper = ,
$account_number = , $extra = );
Parameters
<dollar></dollar>item_list - An associative array keyed by item sku, the value of which contains the quantity ordered. (List of Products)
<dollar></dollar>name - Full name
<dollar></dollar>address1 - Shipping address line 1
<dollar></dollar>address2 - Shipping address line 2
<dollar></dollar>city - City to ship to
<dollar></dollar>state - State to ship to
<dollar></dollar>zip - Postal code to ship to
<dollar></dollar>country - Country to ship to
<dollar></dollar>email - Email address of person placing order
<dollar></dollar>phone - Phone number of person placing order. (Optional)
<dollar></dollar>shipper - Shipper to use for shipment. Must be one of USPS, UPS, FedEx, or Blank. (Optional)
<dollar></dollar>account_number - Account number for shipper. Shipping will be billed to this account. (Optional)
<dollar></dollar>extra - Extra information. (Optional). This can be a string or an array of data. Special uses may be set up with specific vendors for this field.
Returns
Nothing. If no exception was thrown, then success.
Exceptions
AoPSAPI_Exception::INVALID_ITEM - An invalid item ID was submitted
AoPSAPI_Exception::MISSING_PARAMETER - Not all parameters specified. Should not occur if using API library.
AoPSAPI_Exception::INVALID_PARAMETER - An invalid parameter was specified. Usually when shipper is not accurate.
AoPSAPI_Exception::INVALID_PERMISSIONS - API Application does not have permission to submit order
Example
require_once 'AoPSAPI.php';
$api = new AoPSAPI('<api_key>', '<secret_key>');
try
{
$items['intro:algebra'] = 1;
$items['intro:algebra:solutions'] = 1;
$api->order->generate($items, "Santa Claus", "15 North Pole Ln", "",
"North Pole", "SK", "HOH OHO", "CA",
"santa@northpole.com", "", "UPS", "28319472394",
"Extra Info");
}
catch (AoPSAPI_Exception $ex)
{
echo $ex->getMessage() . "
\n";
}