Esempio n. 1
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;
 }
Esempio n. 2
0
 public function delete()
 {
     if (empty($this->id)) {
         return false;
     }
     // Remove WP taxonomy term
     $status = wp_delete_term($this->id, $this->taxonomy);
     // Remove meta data & images
     $status = $status && shopp_rmv_meta($this->id, 'category');
     return $status;
 }
 function migrate_images()
 {
     global $wpdb;
     set_time_limit(900);
     ini_set('memory_limit', '256M');
     $image_path = $this->get_path();
     $image_count = $this->get_image_count();
     $data = $wpdb->get_results("SELECT id, context, name, value FROM " . $wpdb->prefix . "shopp_meta WHERE type = 'image' AND value LIKE '%DBStorage%'");
     $count = 0;
     foreach ($data as $row) {
         $obj = unserialize($row->value);
         if ($obj->storage == 'DBStorage') {
             if (empty($obj->uri)) {
                 shopp_rmv_meta($row->id);
                 continue;
             }
             $blob = $wpdb->get_var($wpdb->prepare("SELECT data FROM " . $wpdb->prefix . "shopp_asset WHERE id = %d", $obj->uri));
             //skip any rows that don't have data in them
             if (empty($blob)) {
                 shopp_rmv_meta($row->id);
                 continue;
             }
             $result = file_put_contents($image_path . $obj->filename, $blob);
             if (!$result) {
                 echo '<div class="error"><p>We\'re having problems with image id: ' . $row->id . '</p></div>';
                 return false;
             }
             //Update our object
             //storage engine
             $obj->storage = 'FSStorage';
             $obj->uri = $obj->filename;
             //set the new object
             $wpdb->update($wpdb->prefix . 'shopp_meta', array('value' => serialize($obj)), array('id' => $row->id));
             if ($count == 500) {
                 return $row->id;
             }
             $count++;
         } else {
             return false;
         }
     }
     return true;
 }
Esempio n. 4
0
/**
 * Remove a meta entry by product id and name
 *
 * @api
 * @since 1.2
 *
 * @param int $product (required) - product id of meta entry to remove
 * @param string $name (required with parent object context) - the meta name
 * @param string $type  (optional default: meta) - the meta type
 * @return bool true if the meta entry was removed, false on failure
 **/
function shopp_rmv_product_meta($product = false, $name = false, $type = 'meta')
{
    if (!$product && !$name) {
        shopp_debug(__FUNCTION__ . ' failed: product and name parameters required.');
        return false;
    }
    return shopp_rmv_meta($product, 'product', $name, $type);
}
Esempio n. 5
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;
}
Esempio n. 6
0
/**
 * Remove a tag term by name or id
 *
 * @api
 * @since 1.2
 *
 * @param mixed $tag (required) int tag term_id or string tag name
 * @return bool true on success, false on failure
 **/
function shopp_rmv_product_tag($tag = '')
{
    if (!$tag) {
        shopp_debug(__FUNCTION__ . " failed: Tag name or id required.");
        return false;
    }
    $tag = is_numeric($tag) ? (int) $tag : $tag;
    $Tag = new ProductTag($tag, is_string($tag) ? 'name' : 'id');
    if (empty($Tag->id)) {
        return false;
    }
    $success = shopp_rmv_meta($Tag->id, 'tag');
    return $success && $Tag->delete();
}