Difference between revisions of "Functions:ordersGetList"
From Whirlwind eCommerce Wiki
(New page: == Description == eV::ordersGetList() retrieves a multidimensional array of order information. Especially useful for order history pages. == Syntax == $array = eV::orderGetList([$userId[,...) |
|||
Line 3: | Line 3: | ||
== Syntax == | == Syntax == | ||
− | $array = eV::orderGetList([$ | + | $array = eV::orderGetList([$fieldList[,$userId]]); |
== Paramaters == | == Paramaters == | ||
− | |||
− | |||
*$fieldList STRING (optional) | *$fieldList STRING (optional) | ||
:: comma-delimited list of fields to be returned. If not passed, all fields will be returned. | :: comma-delimited list of fields to be returned. If not passed, all fields will be returned. | ||
+ | *$userId INT (optional) | ||
+ | :: system designated unique userId - all orders that belong to the user will be returned. Defaults to the current session's user. | ||
+ | |||
== Return Values == | == Return Values == | ||
Line 48: | Line 49: | ||
</pre> | </pre> | ||
− | == | + | == Example == |
− | ; | + | <source lang="php"> |
− | + | ||
− | ; | + | // get listing |
− | + | $arrOrders = eV::ordersGetList("orderId,orderNumber,completeDate,cancelDate,orderTotal"); | |
+ | |||
+ | // start off a table | ||
+ | echo "<table><tr><td>Order Number</td><td>Date</td><td>Total</td></tr>"; | ||
+ | |||
+ | if(!count($arrOrders)){ | ||
+ | // no orders, display message | ||
+ | echo "<tr><td colspan=3>You have no orders at this time</td></tr>"; | ||
+ | } else { | ||
+ | // we have orders, lets loop | ||
+ | foreach($arrOrders as $order) { | ||
+ | // only display orders that are completed and current (not cancelled) | ||
+ | if(!empty($order['completeDate']) && empty($order['cancelDate'])) { | ||
+ | echo "<tr><td><a href=\"index.php?fa=ORDER.invoice&orderNumber=" . $order['orderNumber'] . "\">" . $order['orderNumber'] . "</a></td>"; | ||
+ | echo "<td>" . date('M d, Y',strtotime($order['completeDate'])) . "</td>"; | ||
+ | echo "<td>" . eV::dollarFormat($order['orderGrandTotal'] . "</td></tr>"; | ||
+ | // end if order qualifies to be displayed | ||
+ | }; | ||
+ | // end order loop | ||
+ | }; | ||
+ | // end if !count($arrOrders) | ||
+ | }; | ||
+ | </source> | ||
== See Also == | == See Also == |
Revision as of 19:24, 19 February 2009
Description
eV::ordersGetList() retrieves a multidimensional array of order information. Especially useful for order history pages.
Syntax
$array = eV::orderGetList([$fieldList[,$userId]]);
Paramaters
- $fieldList STRING (optional)
- comma-delimited list of fields to be returned. If not passed, all fields will be returned.
- $userId INT (optional)
- system designated unique userId - all orders that belong to the user will be returned. Defaults to the current session's user.
Return Values
Returns a multidimensional array where the first dimension is the index of the order, and the second dimension is the order's field names:
Array ( [0] => Array ( // fields automatically included [orderId] => INT [orderNumber] => IN [createDate] => DATETIME [completeDate] => DATETIME [cancelDate] => DATETIME [user_firstName] => STR [user_lastName] => STR [user_emailAddress] => STR [ship_firstName] => STR [ship_lastName] => STR [ship_emailAddress] => STR [pay_firstName] => STR [pay_lastName] => STR [pay_emailAddress] => STR [itemTotal] => FLOAT // cost of items in cart added up [discountTotal] => FLOAT // discount totals added up [orderTotal] => FLOAT // cost of items in cart added up, less discounts [taxTotal] => FLOAT // total taxes charged to order [shipTotal] => FLOAT // total shipping charged to order [orderGrandTotal] => FLOAT // sum total of everything (item, tax, ship, less discount) for order ) [1] => Array ( ... ) )
Example
// get listing $arrOrders = eV::ordersGetList("orderId,orderNumber,completeDate,cancelDate,orderTotal"); // start off a table echo "<table><tr><td>Order Number</td><td>Date</td><td>Total</td></tr>"; if(!count($arrOrders)){ // no orders, display message echo "<tr><td colspan=3>You have no orders at this time</td></tr>"; } else { // we have orders, lets loop foreach($arrOrders as $order) { // only display orders that are completed and current (not cancelled) if(!empty($order['completeDate']) && empty($order['cancelDate'])) { echo "<tr><td><a href=\"index.php?fa=ORDER.invoice&orderNumber=" . $order['orderNumber'] . "\">" . $order['orderNumber'] . "</a></td>"; echo "<td>" . date('M d, Y',strtotime($order['completeDate'])) . "</td>"; echo "<td>" . eV::dollarFormat($order['orderGrandTotal'] . "</td></tr>"; // end if order qualifies to be displayed }; // end order loop }; // end if !count($arrOrders) };