当前位置: 首页>>代码示例>>PHP>>正文


PHP update_product_meta函数代码示例

本文整理汇总了PHP中update_product_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP update_product_meta函数的具体用法?PHP update_product_meta怎么用?PHP update_product_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了update_product_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_variation_meta

 private function save_variation_meta($id, $data)
 {
     $product_meta = get_product_meta($id, 'product_metadata', true);
     if (!is_array($product_meta)) {
         $product_meta = array();
     }
     $product_meta = $this->merge_meta_deep($product_meta, $data['product_metadata']);
     // convert to pound to maintain backward compat with shipping modules
     if (isset($data['product_metadata']['weight']) || isset($data['product_metadata']['weight_unit'])) {
         $product_meta['weight'] = wpsc_convert_weight($product_meta['weight'], $product_meta['weight_unit'], 'pound', true);
     }
     update_product_meta($id, 'product_metadata', $product_meta);
     if (isset($data['price'])) {
         update_product_meta($id, 'price', wpsc_string_to_float($data['price']));
     }
     if (isset($data['sale_price'])) {
         $sale_price = wpsc_string_to_float($data['sale_price']);
         if (is_numeric($sale_price)) {
             update_product_meta($id, 'special_price', wpsc_string_to_float($data['sale_price']));
         } else {
             update_product_meta($id, 'special_price', '');
         }
     }
     if (isset($data['sku'])) {
         update_product_meta($id, 'sku', $data['sku']);
     }
     if (isset($data['stock'])) {
         if (is_numeric($data['stock'])) {
             update_product_meta($id, 'stock', (int) $data['stock']);
         } else {
             update_product_meta($id, 'stock', '');
         }
     }
 }
开发者ID:dreamteam111,项目名称:dreamteam,代码行数:34,代码来源:product-variations-page.class.php

示例2: wpsc_update_alt_product_currency

function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice)
{
    global $wpdb;
    $old_curr = get_product_meta($product_id, 'currency', true);
    $sql = $wpdb->prepare("SELECT `isocode` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`= %d", $newCurrency);
    $isocode = $wpdb->get_var($sql);
    $newCurrency = 'currency';
    $old_curr[$isocode] = $newPrice;
    if ($newPrice != '' && $newPrice > 0.0) {
        update_product_meta($product_id, $newCurrency, $old_curr);
    } else {
        if ((empty($old_curr[$isocode]) || 0.0 == $old_curr[$isocode]) && is_array($old_curr)) {
            unset($old_curr[$isocode]);
        }
        update_product_meta($product_id, $newCurrency, $old_curr);
    }
}
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:17,代码来源:product-functions.php

示例3: wpsc_add_product

function wpsc_add_product($product_values)
{
    global $wpdb;
    // takes an array, inserts it into the database as a product
    $success = false;
    $insertsql = "INSERT INTO `" . WPSC_TABLE_PRODUCT_LIST . "` SET";
    $insertsql .= "`name` = '" . $wpdb->escape($product_values['name']) . "',";
    $insertsql .= "`description`  = '" . $wpdb->escape($product_values['description']) . "',";
    $insertsql .= "`additional_description`  = '" . $wpdb->escape($product_values['additional_description']) . "',";
    $insertsql .= "`price` = '" . $wpdb->escape($product_values['price']) . "',";
    $insertsql .= "`quantity_limited` = '" . $wpdb->escape($product_values['quantity_limited']) . "',";
    $insertsql .= "`quantity` = '" . $wpdb->escape($product_values['quantity']) . "',";
    $insertsql .= "`special` = '" . $wpdb->escape($product_values['special']) . "',";
    $insertsql .= "`special_price` = '" . $wpdb->escape($product_values['special_price']) . "',";
    $insertsql .= "`weight` = '" . $wpdb->escape($product_values['weight']) . "',";
    $insertsql .= "`weight_unit` = '" . $wpdb->escape($product_values['weight_unit']) . "',";
    $insertsql .= "`no_shipping` = '" . $wpdb->escape($product_values['no_shipping']) . "',";
    $insertsql .= "`pnp` = '" . $wpdb->escape($product_values['pnp']) . "',";
    $insertsql .= "`international_pnp` = '" . $wpdb->escape($product_values['international_pnp']) . "',";
    $insertsql .= "`donation` = '" . $wpdb->escape($product_values['donation']) . "',";
    $insertsql .= "`display_frontpage` = '" . $wpdb->escape($product_values['display_frontpage']) . "',";
    $insertsql .= "`notax` = '" . $wpdb->escape($product_values['notax']) . "',";
    $insertsql .= "`image` = '0',";
    $insertsql .= "`file` = '0',";
    $insertsql .= "`thumbnail_state` = '0' ;";
    //Insert the data
    if ($wpdb->query($insertsql)) {
        // if we succeeded, we have a product id, we wants it for the next stuff
        $product_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LIMIT 1");
        // add the tags
        if (function_exists('wp_insert_term')) {
            product_tag_init();
            $tags = $product_values['product_tag'];
            if ($tags != "") {
                $tags = explode(',', $tags);
                foreach ($tags as $tag) {
                    $tt = wp_insert_term((string) $tag, 'product_tag');
                }
                $return = wp_set_object_terms($product_id, $tags, 'product_tag');
            }
        }
        $image = wpsc_item_process_image($product_id, $product_values['image_path'], basename($product_values['image_path']), $product_values['width'], $product_values['height'], $product_values['image_resize']);
        if ($image != null) {
            $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = '" . $wpdb->escape($image) . "' WHERE `id`='" . $product_id . "' LIMIT 1");
        }
        // add the product meta values
        if ($product_values['productmeta_values'] != null) {
            foreach ((array) $product_values['productmeta_values'] as $key => $value) {
                if (get_product_meta($product_id, $key) != false) {
                    update_product_meta($product_id, $key, $value);
                } else {
                    add_product_meta($product_id, $key, $value);
                }
            }
        }
        // and the custom meta values
        if ($product_values['new_custom_meta'] != null) {
            foreach ((array) $product_values['new_custom_meta']['name'] as $key => $name) {
                $value = $product_values['new_custom_meta']['value'][(int) $key];
                if ($name != '' && $value != '') {
                    add_product_meta($product_id, $name, $value, false, true);
                }
            }
        }
        // Add the tidy url name
        $tidied_name = trim($product_values['name']);
        $tidied_name = strtolower($tidied_name);
        $url_name = sanitize_title($tidied_name);
        $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`meta_value`, '" . $wpdb->escape($url_name) . "', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ('url_name') AND `meta_value` REGEXP '^(" . $wpdb->escape($url_name) . "){1}(\\d)*\$' ", ARRAY_A);
        $extension_number = '';
        if ($similar_names['count'] > 0) {
            $extension_number = (int) $similar_names['max_number'] + 1;
        }
        $url_name .= $extension_number;
        add_product_meta($product_id, 'url_name', $url_name, true);
        // Add the varations and associated values
        $variations_procesor = new nzshpcrt_variations();
        if ($product_values['variation_values'] != null) {
            $variations_procesor->add_to_existing_product($product_id, $product_values['variation_values']);
        }
        if ($product_values['variation_priceandstock'] != null) {
            $variations_procesor->update_variation_values($product_id, $product_values['variation_priceandstock']);
        }
        // Add the selelcted categories
        $item_list = '';
        if (count($product_values['category']) > 0) {
            foreach ($product_values['category'] as $category_id) {
                $category_id = (int) $category_id;
                $check_existing = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` WHERE `product_id` = " . $product_id . " AND `category_id` = '{$category_id}' LIMIT 1");
                if ($check_existing == null) {
                    $wpdb->query("INSERT INTO `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` ( `product_id` , `category_id` ) VALUES ( '" . $product_id . "', '" . $category_id . "');");
                }
            }
        }
        $success = true;
    }
    return $success;
}
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:98,代码来源:processing.functions.php

示例4: wpsc_item_reassign_file

/**
 * wpsc_item_reassign_file function 
 *
 * @param integer product ID
 * @param string the selected file name;
 */
function wpsc_item_reassign_file($product_id, $selected_files)
{
    global $wpdb;
    $product_file_list = array();
    // initialise $idhash to null to prevent issues with undefined variables and error logs
    $idhash = null;
    /* if we are editing, grab the current file and ID hash */
    if (!$selected_files) {
        // unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
        $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `file` = '0' WHERE `id` = '{$product_id}' LIMIT 1");
        return null;
    }
    foreach ($selected_files as $selected_file) {
        // if we already use this file, there is no point doing anything more.
        $current_fileid = $wpdb->get_var("SELECT `file` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$product_id}' LIMIT 1");
        if ($current_fileid > 0) {
            $current_file_data = $wpdb->get_row("SELECT `id`,`idhash` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` = '{$current_fileid}' LIMIT 1", ARRAY_A);
            if (basename($selected_file) == $file_data['idhash']) {
                //$product_file_list[] = $current_fileid;
                //return $current_fileid;
            }
        }
        $selected_file = basename($selected_file);
        if (file_exists(WPSC_FILE_DIR . $selected_file)) {
            $timestamp = time();
            $file_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `idhash` IN('" . $wpdb->escape($selected_file) . "') LIMIT 1", ARRAY_A);
            $fileid = (int) $file_data['id'];
            // if the file does not have a database row, add one.
            if ($fileid < 1) {
                $mimetype = wpsc_get_mimetype(WPSC_FILE_DIR . $selected_file);
                $filename = $idhash = $selected_file;
                $timestamp = time();
                $wpdb->query("INSERT INTO `" . WPSC_TABLE_PRODUCT_FILES . "` (`product_id`, `filename`  , `mimetype` , `idhash` , `date` ) VALUES ('{$product_id}', '{$filename}', '{$mimetype}', '{$idhash}', '{$timestamp}');");
                $fileid = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `date` = '{$timestamp}' AND `filename` IN ('{$filename}')");
            }
            // update the entry in the product table
            $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `file` = '{$fileid}' WHERE `id` = '{$product_id}' LIMIT 1");
            $product_file_list[] = $fileid;
        }
    }
    //exit('<pre>'.print_r($product_file_list, true).'</pre>');
    update_product_meta($product_id, 'product_files', $product_file_list);
    return $fileid;
}
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:50,代码来源:product-functions.php

示例5: do_action

 do_action('wpsc_product_form_submit', $product_id);
 /* Add or edit tidy url name */
 $tidied_name = trim($_POST['title']);
 $tidied_name = strtolower($tidied_name);
 $url_name = preg_replace(array("/(\\s)+/", "/[^\\w-]+/i"), array("-", ''), $tidied_name);
 $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`meta_value`, '{$url_name}', '')) AS `max_number` FROM `" . $wpdb->prefix . "wpsc_productmeta` WHERE `meta_key` IN ('url_name') AND `meta_value` REGEXP '^({$url_name}){1}(\\d)*\$' ", ARRAY_A);
 $extension_number = '';
 if ($similar_names['count'] > 0) {
     $extension_number = (int) $similar_names['max_number'] + 1;
 }
 $stored_name = get_product_meta($_POST['prodid'], 'url_name', true);
 if (get_product_meta($_POST['prodid'], 'url_name', true) != false) {
     $current_url_name = get_product_meta($_POST['prodid'], 'url_name');
     if ($current_url_name[0] != $url_name) {
         $url_name .= $extension_number;
         update_product_meta($_POST['prodid'], 'url_name', $url_name);
     }
 } else {
     $url_name .= $extension_number;
     add_product_meta($_POST['prodid'], 'url_name', $url_name, true);
 }
 /* update thumbnail images */
 if (!($thumbnail_image == null && $_POST['image_resize'] == 3 && $_POST['current_thumbnail_image'] != null)) {
     if ($thumbnail_image != null) {
         $wpdb->query("UPDATE `" . $wpdb->prefix . "product_list` SET `thumbnail_image` = '" . $thumbnail_image . "' WHERE `id`='" . $_POST['prodid'] . "' LIMIT 1");
     }
 }
 $image_resize = $_POST['image_resize'];
 if (!is_numeric($image_resize) || $image_resize < 1) {
     $image_resize = 0;
 }
开发者ID:alx,项目名称:barceloneta,代码行数:31,代码来源:display-items.php

示例6: save_term_prices

/**
 * @todo - Should probably refactor this at some point - very procedural,
 *         WAY too many foreach loops for my liking :)  But it does the trick
 *
 * @param <type> $term_id
 */
function save_term_prices($term_id)
{
    // First - Saves options from input
    if (isset($_POST['variation_price']) || isset($_POST["apply_to_current"])) {
        $term_prices = get_option('term_prices');
        $term_prices[$term_id]["price"] = sanitize_text_field($_POST["variation_price"]);
        $term_prices[$term_id]["checked"] = isset($_POST["apply_to_current"]) ? "checked" : "unchecked";
        update_option('term_prices', $term_prices);
    }
    // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
    if (isset($_POST["apply_to_current"])) {
        //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
        $products_to_mod = get_objects_in_term($term_id, "wpsc-variation");
        $product_parents = array();
        foreach ((array) $products_to_mod as $get_parent) {
            $post = get_post($get_parent);
            if (!$post->post_parent) {
                $product_parents[] = $post->ID;
            }
        }
        //Now that we have all parent IDs with this term, we can get the children (only the ones that are also in $products_to_mod, we don't want to apply pricing to ALL kids)
        foreach ($product_parents as $parent) {
            $args = array('post_parent' => $parent, 'post_type' => 'wpsc-product');
            $children = get_children($args, ARRAY_A);
            foreach ($children as $childrens) {
                $parent = $childrens["post_parent"];
                $children_ids[$parent][] = $childrens["ID"];
                $children_ids[$parent] = array_intersect($children_ids[$parent], $products_to_mod);
            }
        }
        //Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
        foreach ((array) $children_ids as $parents => $kids) {
            $kids = array_values($kids);
            foreach ($kids as $kiddos) {
                $price = wpsc_determine_variation_price($kiddos);
                update_product_meta($kiddos, 'price', $price);
            }
        }
    }
}
开发者ID:ashik968,项目名称:digiplot,代码行数:46,代码来源:display-items-functions.php

示例7: wpsc_decrement_claimed_stock

/**
	* wpsc_decrement_claimed_stock method
	*
	* @param float a price
	* @return string a price with a currency sign
*/
function wpsc_decrement_claimed_stock($purchase_log_id)
{
    global $wpdb;
    //processed
    $all_claimed_stock = $wpdb->get_results($wpdb->prepare("SELECT `cs`.`product_id`, `cs`.`stock_claimed`, `pl`.`id`, `pl`.`processed` FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` `cs` JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` `pl` ON `cs`.`cart_id` = `pl`.`id` WHERE `cs`.`cart_id` = '%s'", $purchase_log_id));
    if (!empty($all_claimed_stock)) {
        switch ($all_claimed_stock[0]->processed) {
            case 3:
            case 4:
            case 5:
                foreach ((array) $all_claimed_stock as $claimed_stock) {
                    $product = get_post($claimed_stock->product_id);
                    $current_stock = get_post_meta($product->ID, '_wpsc_stock', true);
                    $remaining_stock = $current_stock - $claimed_stock->stock_claimed;
                    update_product_meta($product->ID, 'stock', $remaining_stock);
                    $product_meta = get_product_meta($product->ID, 'product_metadata', true);
                    if ($remaining_stock < 1) {
                        // this is to make sure after upgrading to 3.8.9, products will have
                        // "notify_when_none_left" enabled by default if "unpublish_when_none_left"
                        // is enabled.
                        if (!isset($product_meta['notify_when_none_left'])) {
                            $product_meta['unpublish_when_none_left'] = 0;
                            if (!empty($product_meta['unpublish_when_none_left'])) {
                                $product_meta['unpublish_when_none_left'] = 1;
                                update_product_meta($product->ID, 'product_metadata', $product_meta);
                            }
                        }
                        $email_message = sprintf(__('The product "%s" is out of stock.', 'wpsc'), $product->post_title);
                        if (!empty($product_meta["unpublish_when_none_left"])) {
                            $result = wp_update_post(array('ID' => $product->ID, 'post_status' => $draft));
                            if ($result) {
                                $email_message = __('The product "%s" is out of stock and has been unpublished.', 'wpsc');
                            }
                        }
                        if ($product_meta["notify_when_none_left"] == 1) {
                            wp_mail(get_option('purch_log_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), $email_message);
                        }
                    }
                }
            case 6:
                $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` IN (%s)", $purchase_log_id));
                break;
        }
    }
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:51,代码来源:processing.functions.php

示例8: wpsc_update_files

function wpsc_update_files()
{
    global $wpdb, $user_ID;
    $product_files = $wpdb->get_results("SELECT * FROM " . WPSC_TABLE_PRODUCT_FILES . "");
    $wpsc_update = WPSC_Update::get_instance();
    foreach ($product_files as $product_file) {
        $wpsc_update->check_timeout();
        $variation_post_ids = array();
        if (!empty($product_file->product_id)) {
            $product_post_id = (int) $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_file->product_id));
        } else {
            $product_post_id = (int) $wpdb->get_var("SELECT `id` FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE file=" . $product_file->id);
            $product_post_id = (int) $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id));
        }
        $variation_items = $wpdb->get_col("SELECT `id` FROM " . WPSC_TABLE_VARIATION_PROPERTIES . " WHERE `file` = '{$product_file->id}'");
        if (count($variation_items) > 0) {
            $variation_post_ids = $wpdb->get_col("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = '_wpsc_original_variation_id' AND `meta_value` IN(" . implode(", ", $variation_items) . ")");
        }
        $attachment_template = array('post_mime_type' => $product_file->mimetype, 'post_title' => $product_file->filename, 'post_name' => $product_file->idhash, 'post_content' => '', 'post_parent' => $product_post_id, 'post_type' => "wpsc-product-file", 'post_status' => 'inherit');
        $file_id = wpsc_get_meta($product_file->id, '_new_file_id', 'wpsc_files');
        if ($file_id == null && count($variation_post_ids) == 0) {
            $file_data = $attachment_template;
            $file_data['post_parent'] = $product_post_id;
            $new_file_id = wp_insert_post($file_data);
            wpsc_update_meta($product_file->id, '_new_file_id', $new_file_id, 'wpsc_files');
        }
        if (count($variation_post_ids) > 0) {
            foreach ($variation_post_ids as $variation_post_id) {
                $old_file_id = get_product_meta($variation_post_id, 'old_file_id', true);
                if ($old_file_id == null) {
                    $file_data = $attachment_template;
                    $file_data['post_parent'] = $variation_post_id;
                    $new_file_id = wp_insert_post($file_data);
                    update_product_meta($variation_post_id, 'old_file_id', $product_file->id, 'wpsc_files');
                }
            }
        }
        if (!empty($product_file->preview)) {
            $preview_template = array('post_mime_type' => $product_file->preview_mimetype, 'post_title' => $product_file->preview, 'post_name' => $product_file->filename, 'post_content' => '', 'post_parent' => $new_file_id, 'post_type' => "wpsc-product-preview", 'post_status' => 'inherit');
            wp_insert_post($preview_template);
        }
    }
    $download_ids = $wpdb->get_col("SELECT `id` FROM " . WPSC_TABLE_DOWNLOAD_STATUS . "");
    foreach ($download_ids as $download_id) {
        if (wpsc_get_meta($download_id, '_is_legacy', 'wpsc_downloads') !== 'false') {
            wpsc_update_meta($download_id, '_is_legacy', 'true', 'wpsc_downloads');
        }
    }
}
开发者ID:ashik968,项目名称:digiplot,代码行数:49,代码来源:updating-functions.php

示例9: nzshpcrt_install


//.........这里部分代码省略.........
                $sql = "INSERT INTO " . $wpdb->posts . "\n        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order)\n        VALUES\n        ('1', '{$post_date}', '{$post_date_gmt}', '" . $page['tag'] . "', '', '" . $page['title'] . "', '', 'static', 'closed', 'closed', '', '" . $page['name'] . "', '', '', '{$post_date}', '{$post_date_gmt}', '{$post_parent}', '0')";
            }
            $wpdb->query($sql);
            $post_id = $wpdb->insert_id;
            if ($i == 0) {
                $first_id = $post_id;
            }
            $wpdb->query("UPDATE {$wpdb->posts} SET guid = '" . get_permalink($post_id) . "' WHERE ID = '{$post_id}'");
            update_option($page['option'], get_permalink($post_id));
            if ($page['option'] == 'shopping_cart_url') {
                update_option('checkout_url', get_permalink($post_id));
            }
            $newpages = true;
            $i++;
        }
    }
    if ($newpages == true) {
        wp_cache_delete('all_page_ids', 'pages');
        $wp_rewrite->flush_rules();
    }
    /* adds nice names for permalinks for products */
    $check_product_names = $wpdb->get_results("SELECT `" . $wpdb->prefix . "product_list`.`id`, `" . $wpdb->prefix . "product_list`.`name`, `" . $wpdb->prefix . "wpsc_productmeta`.`meta_key` FROM `" . $wpdb->prefix . "product_list` LEFT JOIN `" . $wpdb->prefix . "wpsc_productmeta` ON `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "wpsc_productmeta`.`product_id` WHERE (`" . $wpdb->prefix . "wpsc_productmeta`.`meta_key` IN ('url_name') AND  `" . $wpdb->prefix . "wpsc_productmeta`.`meta_value` IN (''))  OR ISNULL(`" . $wpdb->prefix . "wpsc_productmeta`.`meta_key`)");
    if ($check_product_names != null) {
        $sql_query = "SELECT `id`, `name` FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN('1')";
        $sql_data = $wpdb->get_results($sql_query, ARRAY_A);
        foreach ((array) $sql_data as $datarow) {
            $tidied_name = trim($datarow['name']);
            $tidied_name = strtolower($tidied_name);
            $url_name = preg_replace(array("/(\\s)+/", "/[^\\w-]+/"), array("-", ''), $tidied_name);
            $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`meta_value`, '{$url_name}', '')) AS `max_number` FROM `" . $wpdb->prefix . "wpsc_productmeta` WHERE `meta_key` LIKE 'url_name' AND `meta_value` REGEXP '^({$url_name}){1}(\\d)*\$' ", ARRAY_A);
            $extension_number = '';
            if ($similar_names['count'] > 0) {
                $extension_number = (int) $similar_names['max_number'] + 1;
            }
            if (get_product_meta($datarow['id'], 'url_name') != false) {
                $current_url_name = get_product_meta($datarow['id'], 'url_name');
                if ($current_url_name[0] != $url_name) {
                    $url_name .= $extension_number;
                    update_product_meta($datarow['id'], 'url_name', $url_name);
                }
            } else {
                $url_name .= $extension_number;
                add_product_meta($datarow['id'], 'url_name', $url_name, true);
            }
        }
    }
    /* adds nice names for permalinks for categories */
    $check_category_names = $wpdb->get_results("SELECT DISTINCT `nice-name` FROM `" . $wpdb->prefix . "product_categories` WHERE `nice-name` IN ('') AND `active` IN ('1')");
    if ($check_category_names != null) {
        $sql_query = "SELECT `id`, `name` FROM `" . $wpdb->prefix . "product_categories` WHERE `active` IN('1')";
        $sql_data = $wpdb->get_results($sql_query, ARRAY_A);
        foreach ((array) $sql_data as $datarow) {
            $tidied_name = trim($datarow['name']);
            $tidied_name = strtolower($tidied_name);
            $url_name = preg_replace(array("/(\\s)+/", "/[^\\w-]+/"), array("-", ''), $tidied_name);
            $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '{$url_name}', '')) AS `max_number` FROM `" . $wpdb->prefix . "product_categories` WHERE `nice-name` REGEXP '^({$url_name}){1}(\\d)*\$' ", ARRAY_A);
            $extension_number = '';
            if ($similar_names['count'] > 0) {
                $extension_number = (int) $similar_names['max_number'] + 1;
            }
            $url_name .= $extension_number;
            $wpdb->query("UPDATE `" . $wpdb->prefix . "product_categories` SET `nice-name` = '{$url_name}' WHERE `id` = '" . $datarow['id'] . "' LIMIT 1 ;");
        }
        $wp_rewrite->flush_rules();
    }
    /* Moves images to thumbnails directory */
    // this code should no longer be needed, as most people will be using a sufficiently new version
    $image_dir = WPSC_FILE_PATH . "/images/";
    $product_images = WPSC_IMAGE_DIR;
    $product_thumbnails = WPSC_THUMBNAIL_DIR;
    if (!is_dir($product_thumbnails)) {
        @mkdir($product_thumbnails, 0775);
    }
    $product_list = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `image` != ''", ARRAY_A);
    foreach ((array) $product_list as $product) {
        if (!glob($product_thumbnails . $product['image'])) {
            $new_filename = $product['id'] . "_" . $product['image'];
            if (file_exists($image_dir . $product['image'])) {
                copy($image_dir . $product['image'], $product_thumbnails . $new_filename);
                if (file_exists($product_images . $product['image'])) {
                    copy($product_images . $product['image'], $product_images . $new_filename);
                }
                $wpdb->query("UPDATE `" . $wpdb->prefix . "product_list` SET `image` = '" . $new_filename . "' WHERE `id`='" . $product['id'] . "' LIMIT 1");
            } else {
                $imagedir = $product_thumbnails;
                $name = $new_filename;
                $new_image_path = $product_images . $product['image'];
                $imagepath = $product['image'];
                $height = get_option('product_image_height');
                $width = get_option('product_image_width');
                if (file_exists($product_images . $product['image'])) {
                    include "extra_image_processing.php";
                    copy($product_images . $product['image'], $product_images . $new_filename);
                    $wpdb->query("UPDATE `" . $wpdb->prefix . "product_list` SET `image` = '" . $new_filename . "' WHERE `id`='" . $product['id'] . "' LIMIT 1");
                }
            }
        }
    }
    // */
}
开发者ID:alx,项目名称:barceloneta,代码行数:101,代码来源:install_and_update.php

示例10: wpsc_resize_image_thumbnail

/**
 * wpsc_resize_image_thumbnail function 
 *
 * @param integer product ID
 * @param integer the action to perform on the image
 * @param integer the width of the thumbnail image
 * @param integer the height of the thumbnail image
 * @param array the custom image array from $_FILES
 */
function wpsc_resize_image_thumbnail($product_id, $image_action = 0, $width = 0, $height = 0, $custom_image = null)
{
    global $wpdb;
    //exit("<pre>".print_r(func_get_args(), true)."</pre>");
    $image_id = $wpdb->get_var("SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$product_id}' LIMIT 1");
    $image = $wpdb->get_var("SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id` = '{$image_id}' LIMIT 1");
    // check if there is an image that is supposed to be there.
    if ($image != '') {
        if (is_numeric($image)) {
        }
        // check that is really there
        if (file_exists(WPSC_IMAGE_DIR . $image)) {
            // if the width or height is less than 1, set the size to the default
            if (($width < 1 || $height < 1) && $image_action == 2) {
                $image_action = 1;
            }
            switch ($image_action) {
                case 0:
                    if (!file_exists(WPSC_THUMBNAIL_DIR . $image)) {
                        copy(WPSC_IMAGE_DIR . $image, WPSC_THUMBNAIL_DIR . $image);
                    }
                    break;
                case 1:
                    // if case 1, replace the provided size with the default size
                    $height = get_option('product_image_height');
                    $width = get_option('product_image_width');
                case 2:
                    // if case 2, use the provided size
                    $image_input = WPSC_IMAGE_DIR . $image;
                    $image_output = WPSC_THUMBNAIL_DIR . $image;
                    if ($width < 1) {
                        $width = 96;
                    }
                    if ($height < 1) {
                        $height = 96;
                    }
                    image_processing($image_input, $image_output, $width, $height);
                    update_product_meta($product_id, 'thumbnail_width', $width);
                    update_product_meta($product_id, 'thumbnail_height', $height);
                    break;
                case 3:
                    $custom_image_name = '';
                    if ($custom_image !== null) {
                        if (move_uploaded_file($custom_image, WPSC_THUMBNAIL_DIR . $image)) {
                            $custom_image_name = $wpdb->escape(basename($image));
                            $image_input = WPSC_THUMBNAIL_DIR . $image;
                            if (function_exists('getimagesize')) {
                                $imagedata = getimagesize($image_input);
                                update_product_meta($product_id, 'thumbnail_width', (int) $imagedata[0]);
                                update_product_meta($product_id, 'thumbnail_height', (int) $imagedata[1]);
                            }
                        }
                    }
                    break;
            }
            if (!file_exists(WPSC_IMAGE_DIR . $image)) {
                $wpdb->query("INSERT INTO `" . WPSC_TABLE_PRODUCT_IMAGES . "` SET `thumbnail_state` = '{$image_action}' WHERE `id`='{$product_id}' LIMIT 1");
                $sql = "INSERT INTO `" . WPSC_TABLE_PRODUCT_IMAGES . "` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )";
                $wpdb->query($sql);
                $image_id = (int) $wpdb->insert_id;
            }
            $sql = "UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `thumbnail_state` = '{$image_action}', `image` = '{$image_id}', `thumbnail_image` = '{$custom_image_name}'  WHERE `id`='{$product_id}' LIMIT 1";
            //exit($sql);
            $wpdb->query($sql);
        } else {
            //if it is not, we need to unset the associated image
            //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '' WHERE `id`='{$product_id}' LIMIT 1");
            //$wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )");
        }
    }
}
开发者ID:alx,项目名称:SimplePress,代码行数:80,代码来源:product-functions.php

示例11: wpsc_decrement_claimed_stock

/**
	* wpsc_decrement_claimed_stock method 
	*
	* @param float a price
	* @return string a price with a currency sign
*/
function wpsc_decrement_claimed_stock($purchase_log_id)
{
    global $wpdb;
    //processed
    $all_claimed_stock = $wpdb->get_results($wpdb->prepare("SELECT `cs`.`product_id`, `cs`.`stock_claimed`, `pl`.`id`, `pl`.`processed` FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` `cs` JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` `pl` ON `cs`.`cart_id` = `pl`.`id` WHERE `cs`.`cart_id` = '%s'", $purchase_log_id));
    if (!empty($all_claimed_stock)) {
        switch ($all_claimed_stock[0]->processed) {
            case 3:
            case 4:
            case 5:
                foreach ((array) $all_claimed_stock as $claimed_stock) {
                    $product = get_post($claimed_stock->product_id);
                    $current_stock = get_post_meta($product->ID, '_wpsc_stock', true);
                    $remaining_stock = $current_stock - $claimed_stock->stock_claimed;
                    update_product_meta($product->ID, 'stock', $remaining_stock);
                    $product_meta = get_product_meta($product->ID, 'product_metadata', true);
                    if ($remaining_stock < 1 && $product_meta["unpublish_when_none_left"] == 1) {
                        wp_mail(get_option('purch_log_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), sprintf(__('Remaining stock of %s is 0. Product was unpublished.', 'wpsc'), $product->post_title));
                        $wpdb->update($wpdb->posts, array('post_status' => 'draft'), array('ID' => $product->ID), '%s', '%d');
                    }
                }
            case 6:
                $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` IN (%s)", $purchase_log_id));
                break;
        }
    }
}
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:33,代码来源:processing.functions.php

示例12: save_term_prices

/**
 * @todo - Should probably refactor this at some point - very procedural,
 *		   WAY too many foreach loops for my liking :)  But it does the trick
 *
 * @param <type> $term_id
 */
function save_term_prices($term_id)
{
    // First - Saves options from input
    if (isset($_POST['variation_price']) || isset($_POST["apply_to_current"])) {
        $term_prices = get_option('term_prices');
        $term_prices[$term_id]["price"] = $_POST["variation_price"];
        $term_prices[$term_id]["checked"] = isset($_POST["apply_to_current"]) ? "checked" : "unchecked";
        update_option('term_prices', $term_prices);
    }
    // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
    if (isset($_POST["apply_to_current"])) {
        //Check for flat, percentile or differential
        $var_price_type = '';
        if (flat_price($_POST["variation_price"])) {
            $var_price_type = 'flat';
        } elseif (differential_price($_POST["variation_price"])) {
            $var_price_type = 'differential';
        } elseif (percentile_price($_POST["variation_price"])) {
            $var_price_type = 'percentile';
        }
        //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
        $products_to_mod = get_objects_in_term($term_id, "wpsc-variation");
        $product_parents = array();
        foreach ((array) $products_to_mod as $get_parent) {
            $post = get_post($get_parent);
            if (!$post->post_parent) {
                $product_parents[] = $post->ID;
            }
        }
        //Now that we have all parent IDs with this term, we can get the children (only the ones that are also in $products_to_mod, we don't want to apply pricing to ALL kids)
        foreach ($product_parents as $parent) {
            $args = array('post_parent' => $parent, 'post_type' => 'wpsc-product');
            $children = get_children($args, ARRAY_A);
            foreach ($children as $childrens) {
                $parent = $childrens["post_parent"];
                $children_ids[$parent][] = $childrens["ID"];
                $children_ids[$parent] = array_intersect($children_ids[$parent], $products_to_mod);
            }
        }
        //Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
        foreach ((array) $children_ids as $parents => $kids) {
            $kids = array_values($kids);
            $parent_pricing = get_product_meta($parents, "price", true);
            foreach ($kids as $kiddos) {
                $child_pricing = get_product_meta($kiddos, "price", true);
                if ($var_price_type == 'flat') {
                    update_product_meta($kiddos, "price", floatval($_POST["variation_price"]));
                } elseif ($var_price_type == 'percentile') {
                    //Are we decreasing or increasing the price?
                    if (strchr($_POST["variation_price"], '-')) {
                        $positive = false;
                    } else {
                        $positive = true;
                    }
                    //Now, let's get the parent product price, +/- by the percentage given
                    $percentage = absint($_POST["variation_price"]) / 100;
                    if ($positive) {
                        $price = $parent_pricing + $parent_pricing * $percentage;
                    } else {
                        $price = $parent_pricing - $parent_pricing * $percentage;
                    }
                    update_product_meta($kiddos, "price", $price);
                } elseif ($var_price_type == 'differential') {
                    //Are we decreasing or increasing the price?
                    if (strchr($_POST["variation_price"], '-')) {
                        $positive = false;
                    } else {
                        $positive = true;
                    }
                    //Now, let's get the parent product price, +/- by the differential given
                    $differential = absint($_POST["variation_price"]);
                    if ($positive) {
                        $price = $parent_pricing + $differential;
                    } else {
                        $price = $parent_pricing - $differential;
                    }
                    update_product_meta($kiddos, "price", $price);
                }
            }
        }
    }
}
开发者ID:hornet9,项目名称:Morato,代码行数:88,代码来源:ajax-and-init.php

示例13: wpsc_decrement_claimed_stock

/**
 * wpsc_decrement_claimed_stock method
 *
 * @param float a price
 * @return string a price with a currency sign
 */
function wpsc_decrement_claimed_stock($purchase_log_id)
{
    // Processed
    $claimed_query = new WPSC_Claimed_Stock(array('cart_id' => $purchase_log_id));
    $all_claimed_stock = $claimed_query->get_purchase_log_claimed_stock();
    do_action('wpsc_pre_decrement_claimed_stock', $purchase_log_id, $claimed_query);
    if (!empty($all_claimed_stock)) {
        do_action('wpsc_decrement_claimed_stock_' . $all_claimed_stock[0]->processed, $purchase_log_id, $claimed_query);
        do_action('wpsc_decrement_claimed_stock', $purchase_log_id, $claimed_query);
        switch ($all_claimed_stock[0]->processed) {
            case 3:
            case 4:
            case 5:
                foreach ((array) $all_claimed_stock as $claimed_stock) {
                    $product = get_post($claimed_stock->product_id);
                    $current_stock = get_post_meta($product->ID, '_wpsc_stock', true);
                    $remaining_stock = $current_stock - $claimed_stock->stock_claimed;
                    update_product_meta($product->ID, 'stock', $remaining_stock);
                    $product_meta = get_product_meta($product->ID, 'product_metadata', true);
                    if ($remaining_stock < 1) {
                        // this is to make sure after upgrading to 3.8.9, products will have
                        // "notify_when_none_left" enabled by default if "unpublish_when_none_left"
                        // is enabled.
                        if (!isset($product_meta['notify_when_none_left'])) {
                            $product_meta['unpublish_when_none_left'] = 0;
                            if (!empty($product_meta['unpublish_when_none_left'])) {
                                $product_meta['unpublish_when_none_left'] = 1;
                                update_product_meta($product->ID, 'product_metadata', $product_meta);
                            }
                        }
                        $email_message = sprintf(__('The product "%s" is out of stock.', 'wp-e-commerce'), $product->post_title);
                        if (!empty($product_meta["unpublish_when_none_left"])) {
                            $result = wp_update_post(array('ID' => $product->ID, 'post_status' => 'draft'));
                            if ($result) {
                                $email_message = sprintf(__('The product "%s" is out of stock and has been unpublished.', 'wp-e-commerce'), $product->post_title);
                            }
                        }
                        if ($product_meta["notify_when_none_left"] == 1) {
                            wp_mail(get_option('purch_log_email'), sprintf(__('%s is out of stock', 'wp-e-commerce'), $product->post_title), $email_message);
                        }
                    }
                }
            case 6:
                $claimed_query = new WPSC_Claimed_Stock(array('cart_id' => $purchase_log_id));
                $claimed_query->clear_claimed_stock(0);
                break;
        }
    }
}
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:55,代码来源:processing.functions.php

示例14: wpsc_install


//.........这里部分代码省略.........
                $sql = "INSERT INTO " . $wpdb->posts . "\r\n        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_type)\r\n        VALUES\r\n        ('1', '{$post_date}', '{$post_date_gmt}', '" . $page['tag'] . "', '', '" . $page['title'] . "', '', 'publish', 'closed', 'closed', '', '" . $page['name'] . "', '', '', '{$post_date}', '{$post_date_gmt}', '{$post_parent}', '0', 'page')";
            } else {
                $sql = "INSERT INTO " . $wpdb->posts . "\r\n        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order)\r\n        VALUES\r\n        ('1', '{$post_date}', '{$post_date_gmt}', '" . $page['tag'] . "', '', '" . $page['title'] . "', '', 'static', 'closed', 'closed', '', '" . $page['name'] . "', '', '', '{$post_date}', '{$post_date_gmt}', '{$post_parent}', '0')";
            }
            $wpdb->query($sql);
            $post_id = $wpdb->insert_id;
            if ($i == 0) {
                $first_id = $post_id;
            }
            $wpdb->query("UPDATE {$wpdb->posts} SET guid = '" . get_permalink($post_id) . "' WHERE ID = '{$post_id}'");
            update_option($page['option'], get_permalink($post_id));
            if ($page['option'] == 'shopping_cart_url') {
                update_option('checkout_url', get_permalink($post_id));
            }
            $newpages = true;
            $i++;
        }
    }
    if ($newpages == true) {
        wp_cache_delete('all_page_ids', 'pages');
        $wp_rewrite->flush_rules();
    }
    /* adds nice names for permalinks for products */
    $check_product_names = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_LIST . "`.`id`, `" . WPSC_TABLE_PRODUCT_LIST . "`.`name`, `" . WPSC_TABLE_PRODUCTMETA . "`.`meta_key` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` LEFT JOIN `" . WPSC_TABLE_PRODUCTMETA . "` ON `" . WPSC_TABLE_PRODUCT_LIST . "`.`id` = `" . WPSC_TABLE_PRODUCTMETA . "`.`product_id` WHERE (`" . WPSC_TABLE_PRODUCTMETA . "`.`meta_key` IN ('url_name') AND  `" . WPSC_TABLE_PRODUCTMETA . "`.`meta_value` IN (''))  OR ISNULL(`" . WPSC_TABLE_PRODUCTMETA . "`.`meta_key`)", ARRAY_A);
    if ($check_product_names != null) {
        foreach ((array) $check_product_names as $datarow) {
            $tidied_name = trim($datarow['name']);
            $tidied_name = strtolower($tidied_name);
            $url_name = sanitize_title($tidied_name);
            $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`meta_value`, '{$url_name}', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` LIKE 'url_name' AND `meta_value` REGEXP '^({$url_name}){1}(\\d)*\$' ", ARRAY_A);
            $extension_number = '';
            if ($similar_names['count'] > 0) {
                $extension_number = (int) $similar_names['max_number'] + 1;
            }
            if (get_product_meta($datarow['id'], 'url_name') != false) {
                $current_url_name = get_product_meta($datarow['id'], 'url_name');
                if ($current_url_name != $url_name) {
                    $url_name .= $extension_number;
                    update_product_meta($datarow['id'], 'url_name', $url_name);
                }
            } else {
                $url_name .= $extension_number;
                add_product_meta($datarow['id'], 'url_name', $url_name, true);
            }
        }
    }
    /* adds nice names for permalinks for categories */
    $check_category_names = $wpdb->get_results("SELECT DISTINCT `nice-name` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `nice-name` IN ('') AND `active` IN ('1')");
    if ($check_category_names != null) {
        $sql_query = "SELECT `id`, `name` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN('1')";
        $sql_data = $wpdb->get_results($sql_query, ARRAY_A);
        foreach ((array) $sql_data as $datarow) {
            $tidied_name = trim($datarow['name']);
            $tidied_name = strtolower($tidied_name);
            $url_name = sanitize_title($tidied_name);
            $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '{$url_name}', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `nice-name` REGEXP '^({$url_name}){1}(\\d)*\$' ", ARRAY_A);
            $extension_number = '';
            if ($similar_names['count'] > 0) {
                $extension_number = (int) $similar_names['max_number'] + 1;
            }
            $url_name .= $extension_number;
            $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` SET `nice-name` = '{$url_name}' WHERE `id` = '" . $datarow['id'] . "' LIMIT 1 ;");
        }
        $wp_rewrite->flush_rules();
    }
    /* Moves images to thumbnails directory */
    // this code should no longer be needed, as most people will be using a sufficiently new version
    $image_dir = WPSC_FILE_PATH . "/images/";
    $product_images = WPSC_IMAGE_DIR;
    $product_thumbnails = WPSC_THUMBNAIL_DIR;
    if (!is_dir($product_thumbnails)) {
        @mkdir($product_thumbnails, 0775);
    }
    $product_list = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `image` != ''", ARRAY_A);
    foreach ((array) $product_list as $product) {
        if (!glob($product_thumbnails . $product['image'])) {
            $new_filename = $product['id'] . "_" . $product['image'];
            if (file_exists($image_dir . $product['image'])) {
                copy($image_dir . $product['image'], $product_thumbnails . $new_filename);
                if (file_exists($product_images . $product['image'])) {
                    copy($product_images . $product['image'], $product_images . $new_filename);
                }
                $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = '" . $new_filename . "' WHERE `id`='" . $product['id'] . "' LIMIT 1");
            } else {
                $imagedir = $product_thumbnails;
                $name = $new_filename;
                $new_image_path = $product_images . $product['image'];
                $imagepath = $product['image'];
                $height = get_option('product_image_height');
                $width = get_option('product_image_width');
                if (file_exists($product_images . $product['image'])) {
                    include "extra_image_processing.php";
                    copy($product_images . $product['image'], $product_images . $new_filename);
                    $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = '" . $new_filename . "' WHERE `id`='" . $product['id'] . "' LIMIT 1");
                }
            }
        }
    }
    // */
}
开发者ID:alx,项目名称:SBek-Arak,代码行数:101,代码来源:install_and_update.php

示例15: wpsc_mass_resize_thumbnails

function wpsc_mass_resize_thumbnails()
{
    global $wpdb;
    check_admin_referer('mass_resize');
    if (isset($_GET['wpsc_options'])) {
        foreach ($_GET['wpsc_options'] as $key => $value) {
            if ($value != get_option($key) and absint($value) > 0) {
                update_option($key, absint($value));
            }
        }
    }
    $height = get_option('product_image_height');
    $width = get_option('product_image_width');
    $product_data = $wpdb->get_results("SELECT `product`.`id`, `product`.`image` AS `image_id`, `images`.`image` AS `file`  FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `product` INNER JOIN  `" . WPSC_TABLE_PRODUCT_IMAGES . "` AS `images` ON `product`.`image` = `images`.`id` WHERE `product`.`image` > 0 ", ARRAY_A);
    foreach ((array) $product_data as $product) {
        $image_input = WPSC_IMAGE_DIR . $product['file'];
        $image_output = WPSC_THUMBNAIL_DIR . $product['file'];
        if ($product['file'] != '' and file_exists($image_input)) {
            image_processing($image_input, $image_output, $width, $height);
            update_product_meta($product['id'], 'thumbnail_width', $width);
            update_product_meta($product['id'], 'thumbnail_height', $height);
        } else {
            $wpdb->query("DELETE FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id` IN('{$product['image_id']}') LIMIT 1");
            $wpdb->query("UPDATE `" . WPSC_TABLE_PRODUCT_LIST . "` SET `image` = NULL WHERE `id` = '" . $product['id'] . "' LIMIT 1");
        }
    }
    //$wpdb->query("DELETE FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN('0')");
    $_SESSION['wpsc_thumbnails_resized'] = true;
    $sendback = wp_get_referer();
    $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], remove_query_arg('tab', $sendback));
    wp_redirect($sendback);
    exit;
}
开发者ID:kasima,项目名称:wp-e-commerce-ezp,代码行数:33,代码来源:ajax-and-init.php


注:本文中的update_product_meta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。