本文整理汇总了PHP中get_product_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP get_product_meta函数的具体用法?PHP get_product_meta怎么用?PHP get_product_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_product_meta函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: wpsc_ajax_ie_save
/**
* wpsc_ajax_ie_save save changes made using inline edit
*
* @public
*
* @3.8
* @returns nothing
*/
function wpsc_ajax_ie_save()
{
$product_post_type = get_post_type_object('wpsc-product');
if (!current_user_can($product_post_type->cap->edit_posts)) {
echo '({"error":"' . __('Error: you don\'t have required permissions to edit this product', 'wpsc') . '", "id": "' . $_POST['id'] . '"})';
die;
}
$product = array('ID' => $_POST['id'], 'post_title' => $_POST['title']);
$id = wp_update_post($product);
if ($id > 0) {
//need parent meta to know which weight unit we are using
$post = get_post($id);
$parent_meta = get_product_meta($post->post_parent, 'product_metadata', true);
$product_meta = get_product_meta($product['ID'], 'product_metadata', true);
if (is_numeric($_POST['weight']) || empty($_POST['weight'])) {
$product_meta['weight'] = wpsc_convert_weight($_POST['weight'], $parent_meta['weight_unit'], 'pound', true);
$product_meta['weight_unit'] = $parent_meta['weight_unit'];
}
update_product_meta($product['ID'], 'product_metadata', $product_meta);
update_product_meta($product['ID'], 'price', (double) $_POST['price']);
update_product_meta($product['ID'], 'special_price', (double) $_POST['special_price']);
update_product_meta($product['ID'], 'sku', $_POST['sku']);
if (!is_numeric($_POST['stock'])) {
update_product_meta($product['ID'], 'stock', '');
} else {
update_product_meta($product['ID'], 'stock', absint($_POST['stock']));
}
$post = get_post($id);
$meta = get_product_meta($id, 'product_metadata', true);
$price = get_product_meta($id, 'price', true);
$special_price = get_product_meta($id, 'special_price', true);
$sku = get_product_meta($id, 'sku', true);
$sku = $sku ? $sku : __('N/A', 'wpsc');
$stock = get_product_meta($id, 'stock', true);
$stock = $stock === '' ? __('N/A', 'wpsc') : $stock;
$results = array('id' => $id, 'title' => $post->post_title, 'weight' => wpsc_convert_weight($meta['weight'], 'pound', $parent_meta['weight_unit']), 'price' => wpsc_currency_display($price), 'special_price' => wpsc_currency_display($special_price), 'sku' => $sku, 'stock' => $stock);
echo '(' . json_encode($results) . ')';
die;
} else {
echo '({"error":"' . __('Error updating product', 'wpsc') . '", "id": "' . $_POST['id'] . '"})';
}
die;
}
开发者ID:hornet9,项目名称:Morato,代码行数:51,代码来源:admin.php
示例4: wpsc_product_image_html
function wpsc_product_image_html($image_name, $product_id)
{
global $wpdb, $wp_query;
if (is_numeric($wp_query->query_vars['product_category'])) {
$category_id = (int) $wp_query->query_vars['product_category'];
} else {
if (is_numeric($_GET['category'])) {
$category_id = (int) $_GET['category'];
} else {
$category_id = (int) get_option('wpsc_default_category');
}
}
$product['height'] = get_product_meta($id, 'thumbnail_height');
$product['width'] = get_product_meta($id, 'thumbnail_width');
$use_thumbnail_image = 'false';
if ($product['height'] > $category['height'] || $product['width'] > $category['width']) {
$use_thumbnail_image = 'true';
}
//list($category['height'], $category['width']) =
if ($category_id > 0) {
$category = $wpdb->get_row("SELECT `image_height` AS `height`, `image_width` AS `width` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` IN ('{$category_id}') LIMIT 1", ARRAY_A);
}
// if there is a height, width, and imagePNG function
if ($category['height'] != null && $category['width'] != null && function_exists('ImagePNG')) {
$image_path = "index.php?productid=" . $product_id . "&thumbnail=" . $use_thumbnail_image . "&width=" . $category['width'] . "&height=" . $category['height'] . "";
} else {
$image_path = WPSC_THUMBNAIL_URL . $image_name;
if (is_ssl()) {
$image_path = str_replace("http://", "https://", $image_path);
}
}
return $image_path;
}
开发者ID:papayalabs,项目名称:htdocs,代码行数:33,代码来源:display.functions.php
示例5: 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
示例6: wpsc_the_variation_stock
/**
* wpsc the variation stock function
* @return mixed - Stock level for the variation or FALSE if it can't be calculated
*/
function wpsc_the_variation_stock()
{
global $wpsc_variations;
if ($wpsc_variations->variation_count > 0) {
$product_id = get_the_ID();
$wpq = array('variations' => $wpsc_variations->variation->slug, 'post_status' => 'inherit', 'post_type' => 'wpsc-product', 'post_parent' => $product_id);
$query = new WP_Query($wpq);
// Should never happen
if ($query->post_count != 1) {
return false;
}
// Get the stock count
$vp_id = $query->posts[0]->ID;
$stock = get_product_meta($vp_id, "stock");
$stock[0] = apply_filters('wpsc_product_variation_stock', $stock[0], $id);
$output = $stock[0];
} else {
return false;
}
return $output;
}
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:25,代码来源:template-tags.php
示例7: wpsc_recreate_product_url_names
function wpsc_recreate_product_url_names()
{
if (!current_user_can('manage_options')) {
wp_die("You don't look like an administrator.");
}
global $wpdb;
$product_data = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')", ARRAY_A);
echo "<pre>";
foreach ($product_data as $product_row) {
$product_id = $product_row['id'];
$tidied_name = trim($product_row['name']);
$tidied_name = strtolower($tidied_name);
$url_name = sanitize_title($tidied_name);
echo "<strong>Product {$product_id}:</strong> {$product_row['name']}\n";
echo "Originally Proposed Name: {$url_name}\n";
$similar_names = (array) $wpdb->get_col("SELECT `meta_value` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `product_id` NOT IN('{$product_id}}') AND `meta_key` IN ('url_name') AND `meta_value` REGEXP '^(" . $wpdb->escape(preg_quote($url_name)) . "){1}[[:digit:]]*\$' ");
if (array_search($url_name, $similar_names) !== false) {
// If it is, try to add a number to the end, if that is taken, try the next highest number...
$i = 0;
do {
$i++;
if ($i > 100) {
break;
}
echo "Proposed Name #{$i}: " . ($url_name . $i) . "\n";
} while (array_search($url_name . $i, $similar_names) !== false);
// Concatenate the first number found that wasn't taken
$url_name .= $i;
}
echo "Accepted Name: {$url_name}\n";
$existing_name = get_product_meta($product_id, 'url_name', true);
if (is_array($existing_name)) {
$existing_name = array_pop($existing_name);
}
if ($existing_name != $url_name) {
update_product_meta($product_id, 'url_name', $url_name);
}
echo "\n\n\n";
}
}
开发者ID:hornet9,项目名称:Morato,代码行数:40,代码来源:display-debug.page.php
示例8: 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
示例9: wpsc_you_save
function wpsc_you_save($args = null)
{
$defaults = array('product_id' => false, 'type' => "percentage", 'variations' => false);
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
global $wpdb;
if (!$product_id) {
if (function_exists('wpsc_the_product_id')) {
//select the variation ID with lowest price
$product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . wpsc_the_product_id() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
if (!$product_id) {
$product_id = wpsc_the_product_id();
}
}
}
if (!$product_id) {
return 0;
}
if ($variations) {
$sale_price = wpsc_calculate_price((int) $_POST['product_id'], $variations, true);
} else {
$sale_price = get_product_meta($product_id, 'special_price', true);
}
//if sale price is zero, false, or anything similar - return false
if (!$sale_price) {
return 0;
}
if ($variations) {
$regular_price = wpsc_calculate_price((int) $_POST['product_id'], $variations, false);
} else {
$regular_price = get_product_meta($product_id, 'price', true);
}
//if actual price is zero, false, or something similar, or is less than sale price - return false
if (!$regular_price || !($sale_price < $regular_price)) {
return 0;
}
switch ($type) {
case "amount":
return $regular_price - $sale_price;
break;
default:
if (number_format(($regular_price - $sale_price) / $regular_price * 100, 2) == 100) {
return 99.98999999999999;
} else {
return number_format(($regular_price - $sale_price) / $regular_price * 100, 2);
}
}
}
开发者ID:hornet9,项目名称:Morato,代码行数:48,代码来源:product-template.php
示例10: save_to_db
/**
* save to database method
* @access public
*
* @param integer purchase log id
*/
function save_to_db($purchase_log_id)
{
global $wpdb, $wpsc_shipping_modules;
if ($method === null) {
$method = $this->cart->selected_shipping_method;
}
if (method_exists($wpsc_shipping_modules[$method], "get_item_shipping")) {
$shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
}
if ($this->cart->has_total_shipping_discount()) {
$shipping = 0;
}
if ($this->apply_tax == true && wpsc_tax_isincluded() == false) {
if (is_numeric($this->custom_tax_rate)) {
$tax_rate = $this->custom_tax_rate;
} else {
$tax_rate = $this->cart->tax_percentage;
}
$tax = $this->unit_price * ($tax_rate / 100);
} else {
$tax = 0;
$tax_rate = 0;
}
$wpdb->query($wpdb->prepare("INSERT INTO `" . WPSC_TABLE_CART_CONTENTS . "` (`prodid`, `name`, `purchaseid`, `price`, `pnp`,`tax_charged`, `gst`, `quantity`, `donation`, `no_shipping`, `custom_message`, `files`, `meta`) VALUES ('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '0', '%s', '%s', NULL)", $this->product_id, $this->product_name, $purchase_log_id, $this->unit_price, (double) $shipping, (double) $tax, (double) $tax_rate, $this->quantity, $this->is_donation, $this->custom_message, serialize($this->custom_file)));
$cart_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `" . WPSC_TABLE_CART_CONTENTS . "` LIMIT 1");
foreach ((array) $this->variation_data as $variation_row) {
$wpdb->query("INSERT INTO `" . WPSC_TABLE_CART_ITEM_VARIATIONS . "` ( `cart_id` , `variation_id` , `value_id` ) VALUES ( '" . $cart_id . "', '" . $variation_row['variation_id'] . "', '" . $variation_row['id'] . "' );");
}
$downloads = get_option('max_downloads');
if ($this->is_downloadable == true) {
//$product_files = $wpdb->get_row("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` = '".$this->product_id."' AND `meta_key` = 'product_files'", ARRAY_A);
//$product_files = unserialize($product_files["meta_value"]);
$product_files = get_product_meta($this->product_id, 'product_files');
if ($this->file_id != null) {
// if the file is downloadable, check that the file is real
if ($wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` IN ('{$this->file_id}')")) {
$unique_id = sha1(uniqid(mt_rand(), true));
$wpdb->query("INSERT INTO `" . WPSC_TABLE_DOWNLOAD_STATUS . "` (`product_id` , `fileid` , `purchid` , `cartid`, `uniqueid`, `downloads` , `active` , `datetime` ) VALUES ( '{$this->product_id}', '{$this->file_id}', '{$purchase_log_id}', '{$cart_id}', '{$unique_id}', '{$downloads}', '0', NOW( ));");
}
} else {
foreach ($product_files as $file) {
// if the file is downloadable, check that the file is real
if ($wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` IN ('{$file}')")) {
$unique_id = sha1(uniqid(mt_rand(), true));
$wpdb->query("INSERT INTO `" . WPSC_TABLE_DOWNLOAD_STATUS . "` (`product_id` , `fileid` , `purchid` , `cartid`, `uniqueid`, `downloads` , `active` , `datetime` ) VALUES ( '{$this->product_id}', '{$file}', '{$purchase_log_id}', '{$cart_id}', '{$unique_id}', '{$downloads}', '0', NOW( ));");
}
}
}
}
do_action('wpsc_save_cart_item', $cart_id, $this->product_id);
}
开发者ID:alx,项目名称:SBek-Arak,代码行数:57,代码来源:cart.class.php
示例11: wpsc_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, post_type)\n VALUES\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 . "\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 `" . 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:papayalabs,项目名称:htdocs,代码行数:101,代码来源:install_and_update.php
示例12: WHERE
/* 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 != $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);
}
}
}
/* creates table to store data on what was bought with what however many times */
if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "also_bought_product'") != $wpdb->prefix . "also_bought_product") {
$wpsc_also_bought_product = "CREATE TABLE `" . $wpdb->prefix . "also_bought_product` (\n `id` bigint(20) unsigned NOT NULL auto_increment,\n `selected_product` bigint(20) unsigned NOT NULL default '0',\n `associated_product` bigint(20) unsigned NOT NULL default '0',\n `quantity` int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (`id`)\n) TYPE=MyISAM;";
$wpdb->query($wpsc_also_bought_product);
}
开发者ID:alx,项目名称:barceloneta,代码行数:31,代码来源:update-to-3.5.2.php
示例13: nzshpcrt_submit_checkout
//.........这里部分代码省略.........
break;
case TXT_WPSC_CITY:
$bad_input_message .= TXT_WPSC_PLEASEENTERAVALIDCITY . "";
break;
case TXT_WPSC_PHONE:
$bad_input_message .= TXT_WPSC_PLEASEENTERAVALIDPHONENUMBER . "";
break;
case TXT_WPSC_COUNTRY:
$bad_input_message .= TXT_WPSC_PLEASESELECTCOUNTRY . "";
break;
// case TXT_WPSC_COUPON:
// $bad_input_message .= TXT_WPSC_COUPON_DOESNT_EXIST . "";
// break;
// case TXT_WPSC_COUPON:
// $bad_input_message .= TXT_WPSC_COUPON_DOESNT_EXIST . "";
// break;
default:
$bad_input_message .= TXT_WPSC_PLEASEENTERAVALID . " " . strtolower($form_data['name']) . ".";
break;
}
$bad_input_message .= "\n\r";
}
}
}
// this here section handles uploading files specified by the user for products
$accepted_file_types['mime'][] = 'image/jpeg';
$accepted_file_types['mime'][] = 'image/gif';
$accepted_file_types['mime'][] = 'image/png';
$accepted_file_types['ext'][] = 'jpeg';
$accepted_file_types['ext'][] = 'jpg';
$accepted_file_types['ext'][] = 'gif';
$accepted_file_types['ext'][] = 'png';
foreach ($_SESSION['nzshpcrt_cart'] as $key => $item) {
$can_have_uploaded_image = get_product_meta($item->product_id, 'can_have_uploaded_image', true);
if ($can_have_uploaded_image[0] == 'on') {
$file_data['name'] = basename($_FILES['uploaded_image']['name'][$key]);
$file_data['type'] = $_FILES['uploaded_image']['type'][$key];
$file_data['tmp_name'] = $_FILES['uploaded_image']['tmp_name'][$key];
$file_data['error'] = $_FILES['uploaded_image']['error'][$key];
$file_data['size'] = $_FILES['uploaded_image']['size'][$key];
$mime_type_data = wpsc_get_mimetype($file_data['tmp_name'], true);
$name_parts = explode('.', basename($file_data['name']));
$extension = array_pop($name_parts);
echo $extension . "<br />";
if ($mime_type_data['is_reliable'] == true) {
$mime_type = $mime_type_data['mime_type'];
} else {
// if we can't use what PHP provides us with, we have to trust the user as there aren't really any other choices.
$mime_type = $file_data['type'];
}
if (array_search($mime_type, $accepted_file_types['mime']) !== false && array_search($extension, $accepted_file_types['ext']) !== false) {
if (is_file(WPSC_USER_UPLOADS_DIR . $file_data['name'])) {
$name_parts = explode('.', basename($file_data['name']));
$extension = array_pop($name_parts);
$name_base = implode('.', $name_parts);
$file_data['name'] = null;
$num = 2;
// loop till we find a free file name, first time I get to do a do loop in yonks
do {
$test_name = "{$name_base}-{$num}.{$extension}";
if (!file_exists(WPSC_USER_UPLOADS_DIR . $test_name)) {
$file_data['name'] = $test_name;
}
$num++;
} while ($file_data['name'] == null);
}
开发者ID:alx,项目名称:barceloneta,代码行数:67,代码来源:submit_checkout_function.php
示例14: wpsc_purchaselog_details_SKU
function wpsc_purchaselog_details_SKU()
{
global $purchlogitem;
// exit('<pre>'.print_r($purchlogitem->purchitem,true).'</pre>');
$meta_value = get_product_meta($purchlogitem->purchitem->prodid, 'sku');
if ($meta_value == '') {
return 'N/A';
} else {
return $meta_value;
}
}
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:11,代码来源:purchaselogs.class.php
示例15: wpsc_purchase_log_csv
function wpsc_purchase_log_csv()
{
global $wpdb, $wpsc_gateways;
get_currentuserinfo();
$count = 0;
if ('key' == $_REQUEST['rss_key'] && current_user_can('manage_options')) {
if (isset($_REQUEST['start_timestamp']) && isset($_REQUEST['end_timestamp'])) {
$start_timestamp = $_REQUEST['start_timestamp'];
$end_timestamp = $_REQUEST['end_timestamp'];
$start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
$start_end_sql = apply_filters('wpsc_purchase_log_start_end_csv', $start_end_sql);
$data = $wpdb->get_results($wpdb->prepare($start_end_sql, $start_timestamp, $end_timestamp), ARRAY_A);
$csv_name = 'Purchase Log ' . date("M-d-Y", $start_timestamp) . ' to ' . date("M-d-Y", $end_timestamp) . '.csv';
} elseif (isset($_REQUEST['m'])) {
$year = (int) substr($_REQUEST['m'], 0, 4);
$month = (int) substr($_REQUEST['m'], -2);
$month_year_sql = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . WPSC_TABLE_PURCHASE_LOGS . "\n\t\t\t\tWHERE YEAR(FROM_UNIXTIME(date)) = %d AND MONTH(FROM_UNIXTIME(date)) = %d\n\t\t\t";
$month_year_sql = apply_filters('wpsc_purchase_log_month_year_csv', $month_year_sql);
$data = $wpdb->get_results($wpdb->prepare($month_year_sql, $year, $month), ARRAY_A);
|
请发表评论