/** * shopp_add_order - create an order from the cart and associate with a customer * * @api * @since 1.2 * * @param int $customer the customer that the order will be created for * @return bool|ShoppPurchase false on failure, Purchase object of recently created order on success **/ function shopp_add_order($customer = false) { // check customer if (!($Customer = shopp_customer((int) $customer))) { shopp_debug(__FUNCTION__ . " failed: Invalid customer."); return false; } if (!shopp_cart_items_count()) { shopp_debug(__FUNCTION__ . " failed: No items in cart."); return false; } $Order = ShoppOrder(); $Order->Customer = $Customer; $Order->Billing = $Customer->Billing; $Order->Billing->cardtype = 'api'; $Order->Shipping = $Customer->Shipping; shopp_add_order_event(false, 'purchase', array('gateway' => 'GatewayFramework')); shopp_empty_cart(); return ($Purchase = ShoppPurchase()) ? $Purchase : false; }
/** * Set or get the marketing status for a customer. * * @api * @since 1.2 * * @param int $customer customer id to check or set * @param mixed $flag (optional default:null) null to return the marketing status, true to turn on marketing for a customer, false to turn off marketing for a customer * @return bool true if marketing accepted, false on failure and if marketing is not accepted. **/ function shopp_customer_marketing($customer = false, $flag = null) { $Customer = shopp_customer($customer); if ($Customer) { if (null === $flag) { return isset($Customer->marketing) && "yes" == $Customer->marketing; } $Customer->marketing = $flag ? "yes" : "no"; $Customer->save(); return "yes" == $Customer->marketing; } return false; }
/** * Retreive only order related information * * order_id * order_id_link * order_id_link_src * order_status * order_status_label * order_warning * purchaser_name * purchaser_email * provider * provider_slug * * @param int $order_id * @return array */ public function get_order_data($order_id) { $order = shopp_order($order_id); $customer = shopp_customer($order->customer); if (false === $order || false === $customer) { return false; } $admin_url = admin_url(sprintf('admin.php?page=shopp-orders&id=%d', $order_id)); $admin_link = sprintf('<a href="%s">%d</a>', $admin_url, $order_id); // Set warning flag for refunded, voided or declined transactions switch ($order->txnstatus) { case 'refunded': case 'voided': case 'auth-failed': $order_warning = true; break; default: $order_warning = false; break; } $data = array('order_id' => $order_id, 'order_id_link' => $admin_link, 'order_id_link_src' => $admin_url, 'order_status' => $order->txnstatus, 'order_status_label' => $this->order_status_label($order->txnstatus), 'order_warning' => $order_warning, 'purchaser_name' => $customer->firstname . ' ' . $customer->lastname, 'purchaser_email' => $customer->email, 'provider' => __CLASS__, 'provider_slug' => 'shopp', 'purchase_time' => get_post_time(Tribe__Date_Utils::DBDATETIMEFORMAT, false, $order_id)); /** * Allow users to filter the Order Data * * @param array An associative array with the Information of the Order * @param string What Provider is been used * @param int Order ID * */ $data = apply_filters('tribe_tickets_order_data', $data, 'shopp', $order_id); return $data; }
/** * Get all the attendees for an event. It returns an array with the following fields: * * order_id * order_status * purchaser_name * purchaser_email * ticket * attendee_id * security * product_id * check_in * provider * * @param $event_id * @return array */ protected function get_attendees($event_id) { $attendees_query = new WP_Query(array('posts_per_page' => -1, 'post_type' => self::ATTENDEE_OBJECT, 'meta_key' => self::ATTENDEE_EVENT_KEY, 'meta_value' => $event_id, 'orderby' => 'ID', 'order' => 'DESC')); if (!$attendees_query->have_posts()) { return array(); } $attendees = array(); foreach ($attendees_query->posts as $attendee) { $order_id = get_post_meta($attendee->ID, self::ATTENDEE_ORDER_KEY, true); $checkin = get_post_meta($attendee->ID, $this->checkin_key, true); $security = get_post_meta($attendee->ID, $this->security_code, true); $product_id = get_post_meta($attendee->ID, self::ATTENDEE_PRODUCT_KEY, true); $admin_url = admin_url(sprintf('admin.php?page=shopp-orders&id=%d', $order_id)); $admin_link = sprintf('<a href="%s">%d</a>', $admin_url, $order_id); $order = shopp_order($order_id); $customer = shopp_customer($order->customer); if (false === $order || false === $customer) { continue; } // Set warning flag for refunded, voided or declined transactions switch ($order->txnstatus) { case 'refunded': case 'voided': case 'auth-failed': $order_warning = true; break; default: $order_warning = false; break; } $attendees[] = array('order_id' => $order_id, 'order_id_link' => $admin_link, 'order_status' => $order->txnstatus, 'order_status_label' => $this->order_status_label($order->txnstatus), 'order_warning' => $order_warning, 'purchaser_name' => $customer->firstname . ' ' . $customer->lastname, 'purchaser_email' => $customer->email, 'ticket' => $this->retrieve_product_name($product_id, $order->purchased), 'attendee_id' => $attendee->ID, 'security' => $security, 'product_id' => $product_id, 'check_in' => $checkin, 'provider' => __CLASS__); } return $attendees; }