/** * shopp_last_customer_order - load the most recent order for a particular customer * * @api * @since 1.2 * * @param int $customer (required) the customer id to load the order for * @return ShoppPurchase object or false on failure **/ function shopp_last_customer_order($customer = false) { if (!$customer || !shopp_customer_exists($customer)) { shopp_debug(__FUNCTION__ . " failed: Invalid or missing customer id."); return false; } $orders = shopp_orders(false, false, true, array($customer), 1); if (is_array($orders) && !empty($orders)) { return reset($orders); } return false; }
/** * Loads downloadable purchase data for this customer (populates the downloads property). */ public function load_downloads(array $options = array()) { $defaults = array('show' => false, 'from' => false, 'to' => false, 'orderby' => 'created', 'order' => 'DESC'); $options = array_merge($defaults, $options); extract($options, EXTR_SKIP); $paidonly = $downloads = true; // Bail out if we can't load customer order data if (!($purchases = shopp_orders($from, $to, true, array($this->id), $show, $order, $orderby, $paidonly, $downloads))) { return; } $this->downloads = array(); foreach ($purchases as $Purchase) { if (!in_array($Purchase->txnstatus, array('captured'))) { continue; } reset($Purchase->purchased); $this->extract_downloads($Purchase->purchased); } }