Exemple #1
0
 /**
  * Sets attendee data on attendee posts
  *
  * @since 4.1
  *
  * @param int $attendee_id Attendee Ticket Post ID
  * @param int $order_id Shopp Order ID
  * @param int $product_id Shopp Product ID
  * @param int $order_attendee_id Attendee number in submitted order
  */
 public function save_attendee_meta_to_ticket($attendee_id, $order_id, $product_id, $order_attendee_id)
 {
     $meta = shopp_meta($order_id, 'purchase', Tribe__Tickets_Plus__Meta::META_KEY, 'meta');
     if (!isset($meta[$product_id])) {
         return;
     }
     if (!isset($meta[$product_id][$order_attendee_id])) {
         return;
     }
     update_post_meta($attendee_id, Tribe__Tickets_Plus__Meta::META_KEY, $meta[$product_id][$order_attendee_id]);
 }
Exemple #2
0
 /**
  * Creates or retrieves temporary account registration information for the order
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return array A list of the registration objects
  **/
 public function registration($args = false)
 {
     if (empty($this->id)) {
         return false;
     }
     $args = func_get_args();
     if (count($args) == 1 && 'cleanup' == reset($args)) {
         return shopp_rmv_meta($this->id, 'purchase', 'registration');
     }
     $registration = array();
     $objectmap = array('ShoppCustomer' => 'Customer', 'BillingAddress' => 'Billing', 'ShippingAddress' => 'Shipping');
     foreach ($args as $Object) {
         $class = is_object($Object) ? get_class($Object) : '';
         $Record = new StdClass();
         $properties = array_keys($Object->_datatypes);
         foreach ($properties as $property) {
             if (isset($Object->{$property})) {
                 $Record->{$property} = $Object->{$property};
             }
         }
         if ('ShoppCustomer' == $class) {
             // hash the password before storage
             $Object->hashpass();
             if (isset($Object->passhash)) {
                 $Record->passhash = $Object->passhash;
             }
             $Record->loginname = $Object->loginname;
         }
         if (isset($objectmap[$class])) {
             $registration[$objectmap[$class]] = $Record;
         }
     }
     if (!empty($registration)) {
         shopp_set_meta($this->id, 'purchase', 'registration', $registration);
     }
     $meta = shopp_meta($this->id, 'purchase', 'registration');
     return $meta;
 }
 /**
  * Helper function that maps the current cart item's addons to the cart item's configured product menu options
  *
  * @internal
  * @since 1.3
  *
  * @return array A combined list of the menu labels list and addons menu map
  **/
 public static function _addon_menus($productid)
 {
     $menus = shopp_meta($productid, 'product', 'options');
     $addonmenus = array();
     $menulabels = array();
     if (isset($menus['a'])) {
         foreach ($menus['a'] as $addonmenu) {
             $menulabels[$addonmenu['id']] = $addonmenu['name'];
             foreach ($addonmenu['options'] as $menuoption) {
                 $addonmenus[$menuoption['id']] = $addonmenu['id'];
             }
         }
     }
     return array($menulabels, $addonmenus);
 }
 function is_image_fsstorage()
 {
     $data = shopp_meta(false, 'shopp', 'image_storage', 'setting');
     if (!empty($data)) {
         foreach ($data as $obj) {
             if ($obj->value == 'FSStorage') {
                 return true;
             }
         }
     }
     return false;
 }
Exemple #5
0
/**
 * Determine if one or more meta records exist based on some combination of context, and/or type, and/or name of the metadata
 *
 * One or more of the parameters must be specified.
 *
 * @api
 * @since 1.2
 *
 * @param string $name (optional) name of the meta entry
 * @param string $context (optional) object context of the meta entry
 * @param string $type (optional default: meta) type of the meta entry
 * @return bool true if one or more meta entries exist
 **/
function shopp_meta_exists($name = false, $context = false, $type = 'meta')
{
    if (!($name || $context)) {
        return false;
    }
    $meta = shopp_meta(false, $context, $name, $type);
    return (bool) $meta;
}
Exemple #6
0
/**
 * shopp_product_variant_set_subscription - for subscription type variants, set subscription parameters.
 *
 * @api
 * @since 1.2
 *
 * @param int/Price $variant (required) The priceline id to set donation settings on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
 * @param array $settings (required) The array of settings. Specify any trial period pricing, and the define the billing cycle.
 * Example array( 	'trial' => array(	'price' => 0.00,	// the trial price
 * 										'cycle' => array (	'interval' => 30, // how many units of the period the trial lasts (day,week,month,year)
 * 															'period' => 'd'  // d for days, w for weeks, m for months, y for years
 * 														 )
 * 									),
 * 					'billcycle' => array(	'cycles' => 12,		// 0 for forever, int number of cycles to repeat the billing
 * 											'cycle' => array (	'interval' => 30, // how many units of the period before the next billing cycle (day,week,month,year)
 * 																'period' => 'd'  // d for days, w for weeks, m for months, y for years
 * 															 )
 * 										)
 * 				)
 * @param string $context (optional default:variant) enforces the priceline is a 'product','variant', or 'addon'
 * @return bool/Price false on failure, true if Price saved, else the modified Price object.
 **/
function shopp_product_variant_set_subscription($variant = false, $settings = array(), $context = 'variant')
{
    $context = 'variant' == $context ? 'variation' : $context;
    $save = true;
    if (is_object($variant) && is_a($variant, 'ShoppPrice')) {
        $Price = $variant;
        $save = false;
    } else {
        if (false == $variant) {
            shopp_debug(__FUNCTION__ . " failed: Variant id required.");
            return false;
        }
        $Price = new ShoppPrice($variant);
        if (empty($Price->id) || $Price->context != $context) {
            shopp_debug(__FUNCTION__ . " failed: No such {$context} with id {$variant}.");
        }
    }
    if ('Subscription' != $Price->type) {
        shopp_debug(__FUNCTION__ . " failed: Variant {$variant} is not Subscription type.  Use shopp_product_variant_set_type to set. ");
        return false;
    }
    $Price->trial = "off";
    if (!empty($Price->id)) {
        $variant_settings = shopp_meta($Price->id, 'price', 'settings');
    }
    if (!is_array($variant_settings)) {
        $variant_settings = array();
    }
    if (isset($settings['trial']) && is_array($settings['trial']) && !empty($settings['trial'])) {
        $Price->trial = "on";
        $variant_settings['recurring']['trial'] = "on";
        foreach ($settings['trial'] as $name => $setting) {
            if (is_array($setting) && empty($setting)) {
                continue;
            }
            switch ($name) {
                case "price":
                    $variant_settings['recurring']['trialprice'] = $setting;
                    break;
                case "cycle":
                    $variant_settings['recurring']['trialint'] = $setting['interval'];
                    $variant_settings['recurring']['trialperiod'] = $setting['period'];
                    break;
            }
        }
    }
    if (!isset($settings['billcycle']) || empty($settings['billcycle'])) {
        shopp_debug(__FUNCTION__ . " failed: Billing cycle required.");
        return false;
    }
    foreach ($settings['billcycle'] as $name => $setting) {
        if (is_array($setting) && empty($setting)) {
            continue;
        }
        switch ($name) {
            case "cycle":
                $variant_settings['recurring']['interval'] = $setting['interval'];
                $variant_settings['recurring']['period'] = $setting['period'];
                break;
            case "cycles":
                $variant_settings['recurring']['cycles'] = $setting;
                break;
        }
    }
    foreach ($variant_settings['recurring'] as $property => $setting) {
        $Price->{$property} = $setting;
    }
    $Price->settings = $variant_settings;
    if ($save) {
        return shopp_set_meta($Price->id, 'price', 'settings', $Price->settings);
    }
    return $Price;
}
Exemple #7
0
 /**
  * Generate and store all the attendees information for a new order.
  *
  * @param OrderEventMessage $order_event
  */
 public function generate_tickets(OrderEventMessage $order_event)
 {
     $order = shopp_order($order_event->order);
     $has_tickets = false;
     $optout = (bool) shopp_meta($order->id, 'purchase', self::ATTENDEE_OPTOUT_KEY);
     // Iterate over each product
     foreach ($order->purchased as $item) {
         $order_attendee_id = 0;
         $event_id = $this->get_related_event($item->product);
         if (empty($event_id)) {
             continue;
         }
         // Iterate over all the amount of tickets purchased (for this product)
         $quantity = intval($item->quantity);
         for ($i = 0; $i < $quantity; $i++) {
             $attendee = array('post_status' => 'publish', 'post_title' => $order->id . ' | ' . $item->name . ' | ' . ($i + 1), 'post_type' => self::ATTENDEE_OBJECT, 'ping_status' => 'closed');
             // Insert individual ticket purchased
             $attendee_id = wp_insert_post($attendee);
             update_post_meta($attendee_id, self::ATTENDEE_PRODUCT_KEY, $item->product);
             update_post_meta($attendee_id, self::ATTENDEE_ORDER_KEY, $order->id);
             update_post_meta($attendee_id, self::ATTENDEE_EVENT_KEY, $event_id);
             update_post_meta($attendee_id, $this->security_code, $this->generate_security_code($order->id, $attendee_id));
             update_post_meta($attendee_id, self::ATTENDEE_OPTOUT_KEY, $optout);
             /**
              * Shopp specific action fired when a Shopp-driven attendee ticket for an event is generated
              *
              * @param $attendee_id ID of attendee ticket
              * @param $event_id ID of event
              * @param $order_id Shopp order ID
              * @param $product_id Shopp product ID
              */
             do_action('event_tickets_shopp_attendee_created', $attendee_id, $event_id, $order, $item->product);
             /**
              * Action fired when an attendee ticket is generated
              *
              * @param $attendee_id ID of attendee ticket
              * @param $order_id ID of order
              * @param $product_id Product ID attendee is "purchasing"
              * @param $order_attendee_id Attendee # for order
              */
             do_action('event_tickets_shopp_ticket_created', $attendee_id, $order->id, $item->product, $order_attendee_id);
             $this->record_attendee_user_id($attendee_id);
             $order_attendee_id++;
         }
         $has_tickets = true;
     }
     if ($has_tickets) {
         shopp_set_meta($order->id, 'purchase', $this->order_has_tickets, true);
         $this->send_tickets($order);
     }
 }
Exemple #8
0
/**
 * Remove a customer, and data associated with the customer
 *
 * @api
 * @since 1.2
 *
 * @param int $customer (required) id of the customer to remove
 * @return bool true on success, false on failure
 **/
function shopp_rmv_customer($customer = false)
{
    if (!$customer) {
        shopp_debug(__FUNCTION__ . " failed: Customer id required.");
        return false;
    }
    $Customer = new ShoppCustomer($customer);
    if (empty($Customer->id)) {
        shopp_debug("shopp_rmv_customer notice: No such customer with id {$customer}");
        return false;
    }
    // Remove Addresses
    $Billing = new BillingAddress($customer, 'customer');
    $Shipping = new ShippingAddress($customer, 'customer');
    if (!empty($Billing->id)) {
        $Billing->delete();
    }
    if (!empty($Shipping->id)) {
        $Shipping->delete();
    }
    // Remove Meta records
    $metas = shopp_meta($customer, 'customer');
    foreach ($metas as $meta) {
        shopp_rmv_meta($meta->id);
    }
    // Remove Customer record
    $Customer->delete();
    return true;
}
Exemple #9
0
 public function load_settings()
 {
     $settings = shopp_meta($this->id, 'price', 'settings');
     if (is_array($settings)) {
         foreach ($settings as $property => $setting) {
             $this->{$property} = $setting;
         }
     }
 }