예제 #1
0
파일: Meta.php 프로젝트: TakenCdosG/chefs
 /**
  * Sets attendee data on order posts
  *
  * @since 4.1
  *
  * @param OrderEventMessage $order_event Shopp order event
  */
 public function save_attendee_meta_to_order(OrderEventMessage $order_event)
 {
     $order = shopp_order($order_event->order);
     $order_items = $order->purchased;
     // Bail if the order is empty
     if (empty($order_items)) {
         return;
     }
     $product_ids = array();
     // gather product ids
     foreach ((array) $order_items as $item) {
         if (empty($item->product)) {
             continue;
         }
         $product_ids[] = $item->product;
     }
     $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
     // build the custom meta data that will be stored in the order meta
     if (!($order_meta = $meta_object->build_order_meta($product_ids))) {
         return;
     }
     // store the custom meta on the order
     shopp_set_meta($order->id, 'purchase', Tribe__Tickets_Plus__Meta::META_KEY, $order_meta);
     // clear out product custom meta data cookies
     foreach ($product_ids as $product_id) {
         $meta_object->clear_meta_cookie_data($product_id);
     }
 }
예제 #2
0
 public function add_pending_referral($order_id = 0)
 {
     if ($this->was_referred()) {
         $this->order = apply_filters('affwp_get_shopp_order', shopp_order($order_id->order));
         $customer_email = $this->order->email;
         if ($this->is_affiliate_email($customer_email)) {
             return;
             // Customers cannot refer themselves
         }
         $description = '';
         foreach ($this->order->purchased as $key => $item) {
             $description .= $item->name;
             if ($key + 1 < count($this->order->purchased)) {
                 $description .= ', ';
             }
         }
         $amount = $this->order->total;
         if (affiliate_wp()->settings->get('exclude_tax')) {
             $amount -= $this->order->tax;
         }
         if (affiliate_wp()->settings->get('exclude_shipping')) {
             $amount -= $this->order->shipping;
         }
         $referral_total = $this->calculate_referral_amount($amount, $order_id->order);
         $this->insert_pending_referral($referral_total, $order_id->order, $description);
         $referral = affiliate_wp()->referrals->get_by('reference', $order_id->order, 'shopp');
         $amount = affwp_currency_filter(affwp_format_amount($referral->amount));
         $name = affiliate_wp()->affiliates->get_affiliate_name($referral->affiliate_id);
         $user = wp_get_current_user();
         $Note = new ShoppMetaObject();
         $Note->parent = $order_id->order;
         $Note->context = 'purchase';
         $Note->type = 'order_note';
         $Note->value = new stdClass();
         $Note->value->author = $user->ID;
         $Note->value->message = sprintf(__('Referral #%d for %s recorded for %s', 'affiliate-wp'), $referral->referral_id, $amount, $name);
         $Note->save();
     }
 }
예제 #3
0
파일: order.php 프로젝트: forthrobot/inuvik
/**
 * shopp_order_lines - get a list of the items associated with an order
 *
 * @api
 * @since 1.2
 *
 * @param int $order (required) the order id
 * @return bool|array false on failure, array of ShoppPurchased line item objects on success
 **/
function shopp_order_lines($order = false)
{
    $Order = shopp_order($order);
    if ($Order) {
        return $Order->purchased;
    }
    return false;
}
예제 #4
0
파일: Main.php 프로젝트: TakenCdosG/chefs
 /**
  * Ensures that tickets belonging to completed orders, or where the payment has been authorized
  * or captured, are flagged as suitable for checkin.
  *
  * In Shopp, the order's transaction status (invoiced, authorized, captured etc) is divorced from
  * the overall order status (completed or pending). While we still wish to accurately reflect the
  * transaction status in the attendee list - because it communicates useful information - it
  * generally shouldn't alone be used to dictate whether check in should be allowed or not.
  *
  * The role this filter plays is to check if the order itself has been marked as "complete" and,
  * if so, it allows checkin by adding the transaction status to the list of statuses for which
  * checkin facilities should be provided. It will also default to treating the "authed" and
  * "captured" statuses as indicating the order is effectively complete.
  *
  * This filter executes on the "event_tickets_attendees_shopp_checkin_stati" hook and so
  * further modifications are possible by adding an additional filter(s) at a higher-than-default
  * priority.
  *
  * @param array $statuses
  * @param int   $order_id
  *
  * @return array
  */
 public function checkin_statuses($statuses, $order_id)
 {
     $order = shopp_order($order_id);
     $allow_checkin = array('authed', 'captured');
     // Orders with a status of 1 are complete, regardless of the actual transaction status
     if (1 === (int) $order->status && !in_array($order->txnstatus, $allow_checkin)) {
         $allow_checkin[] = $order->txnstatus;
     }
     return array_merge($statuses, $allow_checkin);
 }
예제 #5
0
 /**
  * Listen for and handle requests to resend the tickets.
  */
 public function resend_tickets_email()
 {
     // Sanity checks
     if (!isset($_GET['id']) || !isset($_POST[$this->resend_tickets_action]) || !current_user_can('shopp_orders')) {
         return;
     }
     check_admin_referer('meta-box-order', 'meta-box-order-nonce');
     // Try to load the current order
     if (false === ($order = shopp_order($_GET['id']))) {
         return;
     }
     // Resend and add a notice event to record the fact
     $this->send_tickets($order);
     $this->add_tickets_resent_note($order->id);
 }