本文整理汇总了PHP中wpsc_product_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_product_url函数的具体用法?PHP wpsc_product_url怎么用?PHP wpsc_product_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpsc_product_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nzshpcrt_specials
function nzshpcrt_specials($input = null)
{
global $wpdb;
$image_width = get_option('product_image_width');
$image_height = get_option('product_image_height');
$siteurl = get_option('siteurl');
$sql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `special_price` != '0.00' AND `active` IN ('1') ORDER BY RAND() LIMIT 1";
$product = $wpdb->get_results($sql, ARRAY_A);
if ($product != null) {
$output = "<div>";
foreach ($product as $special) {
$special['name'] = htmlentities(stripslashes($special['name']), ENT_QUOTES, "UTF-8");
$output .= "<strong><a class='wpsc_product_title' href='" . wpsc_product_url($special['id'], $special['category']) . "'>" . $special['name'] . "</a></strong><br /> ";
if (is_numeric($special['image'])) {
$image_file_name = $wpdb->get_var("SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id`= '" . $special['image'] . "' LIMIT 1");
if ($image_file_name != '') {
$image_path = "index.php?productid=" . $special['id'] . "&width=" . $image_width . "&height=" . $image_height . "";
$output .= "<img src='" . $image_path . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
}
}
//exit('Widget specisl'.get_option('wpsc_special_description'));
if (get_option('wpsc_special_description') != '1') {
$output .= $special['description'] . "<br />";
}
$variations_processor = new nzshpcrt_variations();
$variations_output = $variations_processor->display_product_variations($special['id'], true, false, true);
$output .= $variations_output[0];
if ($variations_output[1] !== null) {
$special['price'] = $variations_output[1];
$special['special_price'] = 0;
}
if ($variations_output[1] == null) {
$output .= "<span class='oldprice'>" . nzshpcrt_currency_display($special['price'], $special['notax'], false) . "</span><br />";
}
$output .= "<span id='special_product_price_" . $special['id'] . "'><span class='pricedisplay'>";
$output .= nzshpcrt_currency_display($special['price'] - $special['special_price'], $special['notax'], false, $product['id']);
$output .= "</span></span><br />";
$output .= "<form id='specials_" . $special['id'] . "' method='post' action='' onsubmit='submitform(this, null);return false;' >";
$output .= "<input type='hidden' name='product_id' value='" . $special['id'] . "'/>";
$output .= "<input type='hidden' name='item' value='" . $special['id'] . "' />";
$output .= "<input type='hidden' name='wpsc_ajax_action' value='special_widget' />";
if ($special['quantity_limited'] == 1 && $special['quantity'] < 1) {
$output .= TXT_WPSC_PRODUCTSOLDOUT . "";
} else {
//$output .= $variations_processor->display_product_variations($special['id'],true);
$output .= "<input type='submit' name='" . TXT_WPSC_ADDTOCART . "' value='" . TXT_WPSC_ADDTOCART . "' />";
}
$output .= "</form>";
}
$output .= "</div>";
} else {
$output = '';
}
echo $input . $output;
}
示例2: nzshpcrt_latest_product
function nzshpcrt_latest_product($input = null)
{
global $wpdb;
$siteurl = get_option('siteurl');
$latest_product = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
if ($latest_product != null) {
$output = "<div>";
foreach ($latest_product as $special) {
$output .= "<div>";
$output .= "\t<div class='item_image'>";
$output .= "\t\t\t<a href='" . wpsc_product_url($special['id'], $special['category']) . "'>";
if ($special['image'] > 0) {
if (get_option('wpsc_selected_theme') == 'marketplace') {
$src = WPSC_IMAGE_URL . $special['image'];
$output .= "\t\t\t\t<img src='" . "index.php?image_id={$special['image']}&width=100&height=75' title='" . $special['name'] . "' alt='" . $special['name'] . "' />";
} else {
$output .= "\t\t\t\t<img src='" . "index.php?image_id={$special['image']}&width=45&height=25' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
}
} else {
//$output .= "<img src='$siteurl/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='".$special['name']."' alt='".$special['name']."' /><br />";
}
$output .= "\t\t</a>";
$output .= "\t</div>";
$output .= "\t<a href='" . wpsc_product_url($special['id'], $special['category']) . "'>";
$output .= "\t\t<strong>" . stripslashes($special['name']) . "</strong><br />";
$output .= "\t</a>";
$output .= "</div>";
}
$output .= "</div>";
} else {
$output = '';
}
echo $input . $output;
}
示例3: nzshpcrt_latest_product
function nzshpcrt_latest_product($input = null)
{
global $wpdb;
$siteurl = get_option('siteurl');
$latest_product = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
if ($latest_product != null) {
$output = "<div>";
foreach ($latest_product as $special) {
$output .= "<a href='" . wpsc_product_url($special['id'], $special['category']) . "'><div>";
$output .= "<div class='item_image'>";
if ($special['image'] != null && file_exists(WPSC_IMAGE_DIR . $special['image'])) {
if (get_option('wpsc_selected_theme') == 'marketplace') {
$src = WPSC_IMAGE_URL . $special['image'];
$output .= "<img src='index.php?productid=" . $special['id'] . "&width=100&height=70' title='" . $special['name'] . "' alt='" . $special['name'] . "' id='product_image_" . $product['id'] . "' class='product_image'/>";
} else {
$output .= "<img src='" . WPSC_THUMBNAIL_URL . $special['image'] . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
}
} else {
//$output .= "<img src='$siteurl/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='".$special['name']."' alt='".$special['name']."' /><br />";
}
$output .= "</div>";
$output .= "<strong>" . stripslashes($special['name']) . "</strong></a><br><br /> ";
$output .= "</div>";
}
$output .= "</div>";
} else {
$output = '';
}
echo $input . $output;
}
示例4: wpsc_grid_title_and_price
function wpsc_grid_title_and_price(&$product)
{
$output .= "<div class='grid_price'>";
if ($soldout) {
$output .= "<span class='soldoutgrid'>Sold out</span>";
} else {
if ($product['special'] == 1) {
$output .= nzshpcrt_currency_display($product['price'] - $product['special_price'], $product['notax'], false, $product['id']) . "\n\r";
} else {
$output .= nzshpcrt_currency_display($product['price'], $product['notax']) . "\n\r";
}
}
$output .= "</div>";
$output .= "<div class='grid_prodcut_title'><a href='" . wpsc_product_url($product['id']) . "'>" . stripslashes($product['name']) . "</a></div>";
return $output;
}
示例5: nzshpcrt_latest_product
function nzshpcrt_latest_product($input = null)
{
global $wpdb;
$siteurl = get_option('siteurl');
$latest_product = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
if ($latest_product != null) {
$output = "<div><div>";
foreach ($latest_product as $special) {
$output .= "<a href='" . wpsc_product_url($special['id'], $special['category']) . "'><div>";
//$output .= "<a href='".wpsc_product_url($special['id'])."'>";
//$output .= "<a href='".wpsc_product_url($special['id'])."'>";
if ($special['image'] != null) {
$output .= "<img src='{$siteurl}/wp-content/plugins/wp-shopping-cart/product_images/thumbnails/" . $special['image'] . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
} else {
$output .= "<img src='{$siteurl}/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
}
//$output .= "</a>";
$output .= "<strong>" . $special['name'] . "</strong></a><br><br /> ";
//$output .= $special['description']."<br /></div><br>";
// $output .= $special['price'];
/*
$output .= "<span id='special_product_price_".$special['id']."'><span class='pricedisplay'>";
$output .= nzshpcrt_currency_display(($special['price'] - $special['special_price']), $special['notax'],false,$product['id']);
$output .= "</span></span><br /><br>";*/
// $output .= "<form id='specials_".$special['id']."' name='$num' method='post' action='#' onsubmit='submitform(this);return false;' >";
// $output .= "<input type='hidden' name='prodid' value='".$special['id']."'/>";
// $output .= "<input type='hidden' name='item' value='".$special['id']."' />";
//
// if(($special['quantity_limited'] == 1) && ($special['quantity'] < 1))
// {
// $output .= TXT_WPSC_PRODUCTSOLDOUT."";
// }
// else
// {
// //$output .= $variations_processor->display_product_variations($special['id'],true);
// $output .= "<input type='submit' name='".TXT_WPSC_ADDTOCART."' value='".TXT_WPSC_ADDTOCART."' />";
// }
// $output .= "</form>";
}
$output .= "</div></div>";
} else {
$output = '';
}
echo $input . $output;
}
示例6: wpsc_akst_send_mail
function wpsc_akst_send_mail()
{
global $wpdb, $wp_query;
//exit("<pre>".print_r($_REQUEST,true)."</pre>");
$post_id = '';
$to = '';
$name = '';
$email = '';
if (!empty($_REQUEST['wpsc_akst_to'])) {
$to = stripslashes($_REQUEST['wpsc_akst_to']);
$to = strip_tags($to);
$to = str_replace(array(',', "\n", "\t", "\r"), array(), $to);
}
if (!empty($_REQUEST['wpsc_akst_name'])) {
$name = stripslashes($_REQUEST['wpsc_akst_name']);
$name = strip_tags($name);
$name = str_replace(array('"', "\n", "\t", "\r"), array(), $name);
}
if (!empty($_REQUEST['wpsc_akst_email'])) {
$email = stripslashes($_REQUEST['wpsc_akst_email']);
$email = strip_tags($email);
$email = str_replace(array(',', "\n", "\t", "\r"), array(), $email);
}
if (!empty($_REQUEST['wpsc_akst_post_id'])) {
$post_id = intval($_REQUEST['wpsc_akst_post_id']);
}
if (empty($to) || !ak_check_email_address($to) || empty($email) || !ak_check_email_address($email)) {
wp_die(__('Click your <strong>back button</strong> and make sure those e-mail addresses are valid then try again.', 'alexking.org'));
}
// $post = &get_post($post_id);
$headers = "MIME-Version: 1.0\n" . 'From: "' . $name . '" <' . $email . '>' . "\n" . 'Reply-To: "' . $name . '" <' . $email . '>' . "\n" . 'Return-Path: "' . $name . '" <' . $email . '>' . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
$subject = __('Check out this product on ', 'alexking.org') . get_bloginfo('name');
if (is_numeric($_REQUEST['wpsc_akst_product_id'])) {
$permalink = get_option('product_list_url');
$message .= __('Greetings--', 'alexking.org') . "\n\n";
$message .= $name . __(' thinks this will be of interest to you:', 'alexking.org') . "\n\n";
//$message .= ak_decode_entities(get_the_title($post_id))."\n\n";
if ($wp_query->query_vars['product_url_name'] != '') {
$product_id = $wpdb->get_var("SELECT `product_id` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '" . $wp_query->query_vars['product_url_name'] . "' ) ORDER BY `product_id` DESC LIMIT 1");
$message .= wpsc_product_url($product_id);
} else {
if (strstr($permalink, "?") !== false) {
$message .= $permalink . "&product_id=" . $_REQUEST['wpsc_akst_product_id'] . "\n\n";
} else {
// $message .= $permalink."?product_id=".$_REQUEST['wpsc_akst_product_id']."\n\n";
$message .= wpsc_product_url((int) $_REQUEST['wpsc_akst_product_id']) . "\n\n";
}
}
$message .= __('Enjoy.', 'alexking.org') . "\n\n";
$message .= '--' . "\n";
$message .= get_bloginfo('home') . "\n";
} else {
$message = __('Greetings--', 'alexking.org') . "\n\n" . $name . __(' thinks this will be of interest to you:', 'alexking.org') . "\n\n" . ak_decode_entities(get_the_title($post_id)) . "\n\n" . get_permalink($post_id) . "\n\n" . __('Enjoy.', 'alexking.org') . "\n\n" . '--' . "\n" . get_bloginfo('home') . "\n";
}
@wp_mail($to, $subject, $message, $headers);
if (!empty($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
}
header("Location: {$url}");
status_header('302');
die;
}
示例7: wpsc_latest_product
function wpsc_latest_product($args = null, $instance)
{
global $wpdb;
$args = wp_parse_args((array) $args, array('number' => 5));
$siteurl = get_option('siteurl');
$options = get_option('wpsc-widget_latest_products');
$number = isset($instance['number']) ? (int) $instance['number'] : 5;
$image = isset($instance['image']) ? (bool) $instance['image'] : FALSE;
if (isset($instance['width'])) {
$width = $instance['width'];
}
if (isset($instance['height'])) {
$height = $instance['height'];
}
$latest_products = get_posts(array('post_type' => 'wpsc-product', 'numberposts' => $number, 'orderby' => 'post_date', 'post_parent' => 0, 'post_status' => 'publish', 'order' => 'DESC'));
$output = '';
if (count($latest_products) > 0) {
foreach ($latest_products as $latest_product) {
// Link
$output .= '<a href="' . wpsc_product_url($latest_product->ID, null) . '" class="wpsc-product-title">' . stripslashes($latest_product->post_title) . '</a>';
// Thumbnails, if required
if ($image) {
$output .= '<div class="item_image">';
$output .= '<a href="' . wpsc_product_url($latest_product->ID, null) . '">';
$attached_images = (array) get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $latest_product->ID, 'orderby' => 'menu_order', 'order' => 'ASC'));
$attached_image = $attached_images[0];
if ($attached_image->ID > 0) {
$output .= '<img src="' . wpsc_product_image($attached_image->ID, $width, $height) . '" title="' . $latest_product->post_title . '" alt="' . $latest_product->post_title . '" />';
} else {
$output .= '<img class="no-image" id="product_image_' . wpsc_the_product_id() . '" alt="No Image" title="' . wpsc_the_product_title() . '" src="' . WPSC_URL . '/wpsc-theme/images/noimage.png" width="' . $width . '" height="' . $height . '" />';
}
$output .= '<span></span>';
$output .= '</a>';
$output .= '</div>';
}
}
}
echo $output;
}
示例8: a_page_url
function a_page_url($page = null)
{
//exit('<pre>'.print_r($this, true).'</pre>');
$curpage = $this->query_vars['page'];
if ($page != '') {
$this->query_vars['page'] = $page;
}
//global $wpsc_query;
if ($this->is_single === true) {
$this->query_vars['page'] = $curpage;
return wpsc_product_url($this->product['id']);
} else {
$output = wpsc_category_url($this->category);
//exit('PAge <pre>'.print_r($this,true).'</pre>');
if ($this->query_vars['page'] > 1) {
//
if (get_option('permalink_structure')) {
$output .= "page/{$this->query_vars['page']}/";
} else {
$output = add_query_arg('page_number', '', $output);
}
}
// $this->query_vars['page'] = $urpage;
// exit('Whats returned: '.$output);
return $output;
}
}
示例9: wpsc_change_canonical_url
/**
* WPSC canonical URL function
* Needs a recent version
* @since 3.7
* @param int product id
* @return bool true or false
*/
function wpsc_change_canonical_url($url)
{
global $wpdb, $wpsc_query, $post;
// Only change the URL is we're viewing a WP e-Commerce page
if (stristr($post->post_content, '[productspage]')) {
if (isset($wpsc_query->query_vars['product_url_name'])) {
$product_url_name = $wpsc_query->query_vars['product_url_name'];
} else {
$product_url_name = '';
}
// Viewing a single product page
if ($product_url_name != '') {
if (!is_numeric($_GET['product_id'])) {
$product_id = $wpdb->get_var($wpdb->prepare("SELECT product_id FROM " . WPSC_TABLE_PRODUCTMETA . " WHERE meta_key = 'url_name' AND meta_value = %s ORDER BY product_id DESC LIMIT 1", $product_url_name));
} else {
$product_id = absint($_GET['product_id']);
}
if ($product_id > 0) {
$url = wpsc_product_url($product_id);
} else {
$url = get_option('product_list_url');
}
// Viewing a category page
} elseif (absint($wpsc_query->query_vars['category_id']) > 0) {
$url = wpsc_category_url(absint($wpsc_query->query_vars['category_id']));
if ($wpsc_query->query_vars['page'] > 1) {
if (get_option('permalink_structure')) {
$url .= "page/{$wpsc_query->query_vars['page']}/";
} else {
$url .= "&page_number={$wpsc_query->query_vars['page']}";
$url = html_entity_decode($url);
}
}
}
}
return $url;
}
示例10: refresh_item
/**
* refresh_item method, refreshes the item, calculates the prices, gets the name
* @access public
*
* @return array array of monetary and other values
*/
function refresh_item()
{
global $wpdb, $wpsc_shipping_modules, $wpsc_cart;
$product_id = $this->product_id;
$product = get_post($this->product_id);
$product_meta = get_metadata('post', $this->product_id);
$this->sku = get_post_meta($product_id, '_wpsc_sku', true);
$price = get_post_meta($product_id, '_wpsc_price', true);
$special_price = get_post_meta($product_id, '_wpsc_special_price', true);
$product_meta = get_post_meta($product_id, '_wpsc_product_metadata');
$this->stock = get_post_meta($product_id, '_wpsc_stock', true);
$this->is_donation = get_post_meta($product_id, '_wpsc_is_donation', true);
if (isset($special_price) && $special_price > 0 && $special_price < $price) {
$price = $special_price;
}
$priceandstock_id = 0;
$this->weight = isset($product_meta[0]['weight']) ? $product_meta[0]["weight"] : 0;
// if we are using table rate price
if (isset($product_meta[0]['table_rate_price'])) {
$levels = $product_meta[0]['table_rate_price'];
if (!empty($levels['quantity'])) {
foreach ((array) $levels['quantity'] as $key => $qty) {
if ($this->quantity >= $qty) {
$unit_price = $levels['table_price'][$key];
if ($unit_price != '') {
$price = $unit_price;
}
}
}
}
}
$price = apply_filters('wpsc_price', $price, $product_id);
// create the string containing the product name.
$this->product_name = $this->get_title('raw');
$this->priceandstock_id = $priceandstock_id;
$this->meta = $product_meta;
// change no_shipping to boolean and invert it
if (isset($product_meta[0]['no_shipping']) && $product_meta[0]['no_shipping'] == 1) {
$this->uses_shipping = 0;
} else {
$this->uses_shipping = 1;
}
$quantity_limited = get_product_meta($product_id, 'stock', true);
$this->has_limited_stock = (bool) $quantity_limited;
if ($this->is_donation == 1) {
$this->unit_price = (double) $this->provided_price;
} else {
$this->unit_price = (double) $price;
}
$this->total_price = $this->unit_price * $this->quantity;
if ($product->post_parent) {
$category_data = get_the_product_category($product->post_parent);
} else {
$category_data = get_the_product_category($product_id);
}
$this->category_list = array();
$this->category_id_list = array();
foreach ((array) $category_data as $category_row) {
$this->category_list[] = $category_row->slug;
$this->category_id_list[] = $category_row->term_id;
}
//wpec_taxes - calculate product tax and add to total price
$wpec_taxes_controller = new wpec_taxes_controller();
if ($wpec_taxes_controller->wpec_taxes_isincluded() && $wpec_taxes_controller->wpec_taxes_isenabled()) {
$taxes = $wpec_taxes_controller->wpec_taxes_calculate_included_tax($this);
$this->tax_rate = $taxes['rate'];
$this->tax = $taxes['tax'];
}
$this->product_url = wpsc_product_url($product_id);
if (!is_array($this->variation_values)) {
$attach_parent = $product_id;
} else {
$attach_parent = $wpdb->get_var($wpdb->prepare("SELECT post_parent FROM {$wpdb->posts} WHERE ID = %d", $product_id));
}
$att_img_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_parent' => $attach_parent, 'orderby' => 'menu_order', 'order' => 'DESC');
$attached_image = get_posts($att_img_args);
if ($attached_image != null) {
$this->thumbnail_image = array_shift($attached_image);
}
$product_files = (array) get_posts(array('post_type' => 'wpsc-product-file', 'post_parent' => $this->product_id, 'numberposts' => -1, 'post_status' => 'inherit'));
if (count($product_files) > 0) {
$this->file_id = null;
$this->is_downloadable = true;
} else {
$this->file_id = null;
$this->is_downloadable = false;
}
if (isset($this->cart->selected_shipping_method) && isset($wpsc_shipping_modules[$this->cart->selected_shipping_method]) && is_callable(array($wpsc_shipping_modules[$this->cart->selected_shipping_method], "get_item_shipping"))) {
$this->shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
}
// update the claimed stock here
$this->update_claimed_stock();
do_action_ref_array('wpsc_refresh_item', array(&$this));
}
示例11: wpsc_product_comments
/**
* wpsc product comments function
* @return string - javascript for the intensedebate comments
*/
function wpsc_product_comments()
{
global $wpsc_query;
$output = '';
// add the product comments
if (get_option('wpsc_enable_comments') == 1) {
$enable_for_product = get_product_meta($wpsc_query->product['id'], 'enable_comments');
if (get_option('wpsc_comments_which_products') == 1 && $enable_for_product == '' || $enable_for_product == 'yes') {
$output = "<script>\n\t\t\t\tvar idcomments_acct = '" . esc_js(get_option('wpsc_intense_debate_account_id')) . "';\n\t\t\t\tvar idcomments_post_id = 'product_" . $wpsc_query->product['id'] . "';\n\t\t\t\tvar idcomments_post_url = encodeURIComponent('" . wpsc_product_url($wpsc_query->product['id'], null, false) . "');\n\t\t\t\t</script>\n\t\t\t\t<span id=\"IDCommentsPostTitle\" style=\"display:none\"></span>\n\t\t\t\t<script type='text/javascript' src='https://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>\n\t\t\t\t";
}
}
return $output;
}
示例12: get_option
$selected_category = "&category_id=" . $_GET['category'] . "";
}
$self = get_option('siteurl') . "/index.php?rss=true&action=product_list{$selected_category}";
$product_list = $wpdb->get_results($sql, ARRAY_A);
header("Content-Type: application/xml; charset=UTF-8");
header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
$output = "<?xml version='1.0'?>\n\r";
$output .= "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:product='http://www.buy.com/rss/module/productV2/'>\n\r";
$output .= " <channel>\n\r";
$output .= " <title>" . get_option('blogname') . " Products</title>\n\r";
$output .= " <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
$output .= " <description>This is the WP E-Commerce Product List RSS feed</description>\n\r";
$output .= " <generator>WP E-Commerce Plugin</generator>\n\r";
$output .= " <atom:link href='{$self}' rel='self' type='application/rss+xml' />";
foreach ($product_list as $product) {
$purchase_link = wpsc_product_url($product['id']);
$output .= " <item>\n\r";
$output .= " <title>" . htmlentities(stripslashes($product['name']), ENT_NOQUOTES, 'UTF-8') . "</title>\n\r";
$output .= " <link>{$purchase_link}</link>\n\r";
//$output .= " <description>".htmlentities(stripslashes($product['description']), ENT_NOQUOTES, 'UTF-8')."</description>\n\r";
$output .= " <description><![CDATA[\n" . htmlentities(stripslashes($product['description']), ENT_NOQUOTES, 'UTF-8') . "\n]]></description>\n\r";
$output .= " <pubDate>" . date("r") . "</pubDate>\n\r";
$output .= " <guid>{$purchase_link}</guid>\n\r";
if ($product['thumbnail_image'] != null) {
$image_file_name = $product['thumbnail_image'];
} else {
$image_file_name = $product['image'];
}
$image_path = WPSC_THUMBNAIL_DIR . $image_file_name;
if (is_file($image_path) && filesize($image_path) > 0) {
$image_data = @getimagesize($image_path);
示例13: refresh_item
/**
* refresh_item method, refreshes the item, calculates the prices, gets the name
* @access public
*
* @return array array of monetary and other values
*/
function refresh_item()
{
global $wpdb, $wpsc_shipping_modules, $wpsc_cart;
$product = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$this->product_id}' LIMIT 1", ARRAY_A);
$priceandstock_id = 0;
if (defined('WPSC_ADD_DEBUG_PAGE') && constant('WPSC_ADD_DEBUG_PAGE') == true) {
$this->product_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$this->product_id}' LIMIT 1", ARRAY_A);
}
if (count($this->variation_values) > 0) {
// if there are variations, get the price of the combination and the names of the variations.
$variation_data = $wpdb->get_results("SELECT *FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id` IN ('" . implode("','", $this->variation_values) . "')", ARRAY_A);
$this->variation_data = $variation_data;
$variation_names = array();
$variation_ids = array();
foreach ($variation_data as $variation_row) {
$variation_names[] = $variation_row['name'];
$variation_ids[] = $variation_row['variation_id'];
}
asort($variation_ids);
$variation_id_string = implode(",", $variation_ids);
$priceandstock_id = $wpdb->get_var("SELECT `priceandstock_id` FROM `" . WPSC_TABLE_VARIATION_COMBINATIONS . "` WHERE `product_id` = '{$this->product_id}' AND `value_id` IN ( '" . implode("', '", $this->variation_values) . "' ) AND `all_variation_ids` IN('{$variation_id_string}') GROUP BY `priceandstock_id` HAVING COUNT( `priceandstock_id` ) = '" . count($this->variation_values) . "' LIMIT 1");
$priceandstock_values = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_VARIATION_PROPERTIES . "` WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A);
$price = $priceandstock_values['price'];
$weight = wpsc_convert_weights($priceandstock_values['weight'], $priceandstock_values['weight_unit']);
$file_id = $priceandstock_values['file'];
} else {
$priceandstock_id = 0;
$weight = wpsc_convert_weights($product['weight'], $product['weight_unit']);
// otherwise, just get the price.
if ($product['special_price'] > 0 and $product['price'] - $product['special_price'] >= 0) {
$sale_discount = (double) $product['special_price'];
} else {
$sale_discount = 0;
}
$price = $product['price'] - $sale_discount;
$file_id = $product['file'];
// if we are using table rate price
$levels = get_product_meta($this->product_id, 'table_rate_price');
if ($levels != '') {
foreach ((array) $levels['quantity'] as $key => $qty) {
if ($this->quantity >= $qty) {
$unit_price = $levels['table_price'][$key];
if ($unit_price != '') {
$price = $unit_price;
}
}
}
}
}
$price = apply_filters('wpsc_do_convert_price', $price);
// create the string containing the product name.
$product_name = $product['name'];
if (count($variation_names) > 0) {
$product_name .= " (" . implode(", ", $variation_names) . ")";
}
$this->product_name = $product_name;
$this->priceandstock_id = $priceandstock_id;
$this->is_donation = (bool) $product['donation'];
// change notax to boolean and invert it
$this->apply_tax = !(bool) $product['notax'];
// change no_shipping to boolean and invert it
$this->uses_shipping = !(bool) $product['no_shipping'];
$this->has_limited_stock = (bool) (int) $product['quantity_limited'];
if ($this->is_donation == 1) {
$this->unit_price = $this->provided_price;
} else {
$this->unit_price = $price;
}
$this->weight = $weight;
$this->total_price = $this->unit_price * $this->quantity;
$category_data = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id`,`" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`nice-name` FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` , `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`product_id` IN ('" . $product['id'] . "') AND `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`category_id` = `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id` AND `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`active` IN('1')", ARRAY_A);
$this->category_list = array();
$this->category_id_list = array();
foreach ($category_data as $category_row) {
$this->category_list[] = $category_row['nice-name'];
$this->category_id_list[] = $category_row['id'];
}
if ($this->apply_tax == true) {
$this->taxable_price = $this->total_price;
$custom_tax = get_product_meta($this->product_id, 'custom_tax');
if (is_numeric($custom_tax)) {
$this->custom_tax_rate = $custom_tax;
$this->tax = $this->taxable_price * ($this->custom_tax_rate / 100);
} else {
$this->tax = $this->taxable_price * ($wpsc_cart->tax_percentage / 100);
}
}
$this->product_url = wpsc_product_url($this->product_id);
$this->image_id = $product['image'];
if ($product['thumbnail_image'] != null) {
$this->thumbnail_image = $product['thumbnail_image'];
} else {
$this->thumbnail_image = $product['image'];
}
//.........这里部分代码省略.........
示例14: wpsc_generate_product_feed
function wpsc_generate_product_feed()
{
global $wpdb;
// Don't cache feed under WP Super-Cache
define('DONOTCACHEPAGE', TRUE);
$siteurl = get_option('siteurl');
// Allow limiting
if (is_numeric($_GET['limit'])) {
$limit = "LIMIT " . $_GET['limit'] . "";
} else {
$limit = '';
}
$selected_category = '';
$selected_product = '';
if (is_numeric($_GET['product_id'])) {
$selected_product = "&product_id=" . $_GET['product_id'] . "";
$sql = " SELECT p.*,\n\t\t pi.image\n\t\t FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t ON `p`.`image` = `pi`.`id`\n\t\t AND `pi`.`product_id` = `p`.`id`\n\t\t WHERE `active` = '1'\n\t\t AND `publish` = '1'\n\t\t AND p.id = '" . $_GET['product_id'] . "'\n\t\t LIMIT 1";
} elseif (is_numeric($_GET['category_id'])) {
$selected_category = "&category_id=" . $_GET['category_id'] . "";
$sql = "SELECT `p`.*,\n\t\t `pi`.`image`\n\t\t FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t ON `p`.`image` = `pi`.`id`\n\t\t AND `p`.`id` = `pi`.`product_id`\n\t\t LEFT JOIN `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` ca\n\t\t ON `p`.`id` = `ca`.`product_id`\n\t\t WHERE `p`.`active` = '1'\n\t\t AND `p`.`publish` = '1'\n\t\t AND `ca`.`category_id` IN ('" . $_GET['category_id'] . "')\n\t\t {$limit}";
} else {
$sql = "SELECT p.*,\n\t\t pi.image\n\t\t FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t ON `p`.`image` = `pi`.`id`\n\t\t AND `pi`.`product_id` = `p`.`id`\n\t\t WHERE `active` ='1'\n\t\t AND `publish` = '1'\n\t\t ORDER BY `id`\n\t\t DESC {$limit}";
}
$self = get_option('siteurl') . "/index.php?rss=true&action=product_list{$selected_category}{$selected_product}";
$product_list = $wpdb->get_results($sql, ARRAY_A);
header("Content-Type: application/xml; charset=UTF-8");
header('Content-Disposition: inline; filename="e-Commerce_Product_List.rss"');
$output = "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
$output .= "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
$google_checkout_note = FALSE;
if ($_GET['xmlformat'] == 'google') {
$output .= ' xmlns:g="http://base.google.com/ns/1.0"';
// Is Google Checkout available as a payment gateway
$selected_gateways = get_option('custom_gateway_options');
if (in_array('google', $selected_gateways)) {
$google_checkout_note = TRUE;
}
} else {
$output .= ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
}
$output .= ">\n\r";
$output .= " <channel>\n\r";
$output .= " <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
$output .= " <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
$output .= " <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
$output .= " <generator>WP e-Commerce Plugin</generator>\n\r";
$output .= " <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
foreach ($product_list as $product) {
$purchase_link = wpsc_product_url($product['id']);
$output .= " <item>\n\r";
if ($google_checkout_note) {
$output .= " <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
}
$output .= " <title><![CDATA[" . stripslashes($product['name']) . "]]></title>\n\r";
$output .= " <link>{$purchase_link}</link>\n\r";
$output .= " <description><![CDATA[" . stripslashes($product['description']) . "]]></description>\n\r";
$output .= " <pubDate>" . date("r") . "</pubDate>\n\r";
$output .= " <guid>{$purchase_link}</guid>\n\r";
if ($product['thumbnail_image'] != null) {
$image_file_name = $product['thumbnail_image'];
$image_path = WP_CONTENT_DIR . "/uploads" . "/wpsc/product_images/thumbnails/{$image_file_name}";
$image_link = WP_CONTENT_URL . "/uploads" . "/wpsc/product_images/thumbnails/" . rawurlencode($image_file_name);
} else {
$image_file_name = $product['image'];
$image_path = WP_CONTENT_DIR . "/uploads" . "/wpsc/product_images/{$image_file_name}";
$image_link = WP_CONTENT_URL . "/uploads" . "/wpsc/product_images/" . rawurlencode($image_file_name);
}
//$image_path = WP_CONTENT_DIR."/uploads"."/wpsc/product_images/thumbnails/{$image_file_name}";
if (is_file($image_path) && filesize($image_path) > 0) {
$image_data = @getimagesize($image_path);
// $image_link = WP_CONTENT_URL."/uploads"."/wpsc/product_images/thumbnails/".urlencode($image_file_name);
if ($_GET['xmlformat'] == 'google') {
$output .= " <g:image_link>{$image_link}</g:image_link>\n\r";
} else {
$output .= " <enclosure url='{$image_link}' length='" . filesize($image_path) . "' type='" . $image_data['mime'] . "' width='" . $image_data[0] . "' height='" . $image_data[1] . "' />\n\r";
}
}
if ($_GET['xmlformat'] == 'google') {
$output .= " <g:price>" . $product['price'] . "</g:price>\n\r";
//$output .= " <g:condition>new</g:condition>\n\r";
$meta_sql = "SELECT meta_key, meta_value \n\t\t FROM `" . WPSC_TABLE_PRODUCTMETA . "` pm\n WHERE `pm`.`product_id` = '" . $product['id'] . "'\n AND `pm`.`meta_key` LIKE 'g:%'";
$google_elements = $wpdb->get_results($meta_sql, ARRAY_A);
$google_elements = apply_filters('wpsc_google_elements', array('product_id' => $product['id'], 'elements' => $google_elements));
$google_elements = $google_elements['elements'];
$done_condition = FALSE;
if (count($google_elements)) {
foreach ($google_elements as $gelement) {
$output .= " <" . $gelement['meta_key'] . ">";
$output .= "<![CDATA[" . $gelement['meta_value'] . "]]>";
$output .= "</" . $gelement['meta_key'] . ">\n\r";
if ($gelement['meta_key'] == 'g:condition') {
$done_condition = TRUE;
}
}
}
if (!$done_condition) {
$output .= " <g:condition>new</g:condition>\n\r";
}
} else {
$output .= " <product:price>" . $product['price'] . "</product:price>\n\r";
//.........这里部分代码省略.........
示例15: show_cats_brands
function show_cats_brands($category_group = null, $display_method = null, $order_by = 'name', $image = null)
{
global $wpdb;
if ($category_group == null) {
$category_group = $wpdb->get_var("SELECT `id` FROM `" . $wpdb->prefix . "wpsc_categorisation_groups` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 ");
} else {
$category_group = (int) $category_group;
}
// Show cats & brands list if displaying on every page or if on a shop page (bit hacky but out of time).
if (get_option('cat_brand_loc') != 3 && !function_exists("nzshpcrt_display_categories_groups") && $display_method != 'sidebar') {
return;
}
if (get_option('permalink_structure') != '') {
$seperator = "?";
} else {
$seperator = "&";
}
$output = "<div class='PeSwitcher'>";
switch (get_option('show_categorybrands')) {
case 1:
$output .= "<ul id='PeCatsBrandsBoth' class='category_brand_header'><li id='PeSwitcherFirst'><a href='' onclick='return prodgroupswitch(\"categories\");'>" . TXT_WPSC_CATEGORIES . "</a> | <a href='' onclick='return prodgroupswitch(\"brands\");'>" . TXT_WPSC_BRANDS . "</a></li></ul>";
break;
}
$output .= "</div>";
$output .= "<div class='PeCatsBrands'>";
if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 2) {
$output .= "<div class='PeCategories categorydisplay'>";
$categories = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_categories` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '0' ORDER BY `" . $wpdb->escape($order_by) . "` ASC", ARRAY_A);
if ($categories != null) {
$output .= "<ul class='PeCategories'>";
foreach ($categories as $option) {
// Adrian - check option for category count
if (get_option('show_category_count') == 1) {
//show product count for each category
$count_sql = "SELECT count(*) FROM `" . $wpdb->prefix . "item_category_associations` WHERE `category_id` = '" . $option['id'] . "'";
$count = $wpdb->get_var($count_sql);
$addCount = " [" . $count . "]";
}
//end get_option
// Adrian - if sliding category type selected, NO link for category text, mootools.js creates the linkable sliders onDomReady.
if (get_option('catsprods_display_type') == 1) {
$output .= "<li class='MainCategory'><strong class='category'>" . stripslashes($option['name']) . $addCount . "</strong>";
} else {
// Adrian - otherwise create normal category text with or without product count
if (!$image) {
$output .= "<li class='MainCategory'><strong class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . $addCount . "</a></strong>";
} else {
$output .= "<li class='MainCategory'><img src='" . get_option('siteurl') . "/wp-content/uploads/wpsc/category_images/" . $option['image'] . "'><br><strong class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . $addCount . "</a></strong>";
}
}
//end get_option
$subcategory_sql = "SELECT * FROM `" . $wpdb->prefix . "product_categories` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '" . $option['id'] . "' ORDER BY `id`";
$subcategories = $wpdb->get_results($subcategory_sql, ARRAY_A);
if ($subcategories != null) {
$output .= display_subcategories($option['id']);
} else {
// Adrian - check if the user wants categories only or sliding categories
if (get_option('catsprods_display_type') == 1) {
// Adrian - display all products for that category
$product_sql = "SELECT product_id FROM `" . $wpdb->prefix . "item_category_associations` WHERE `category_id` = '" . $option['id'] . "'";
$productIDs = $wpdb->get_results($product_sql, ARRAY_A);
if ($productIDs != null) {
$output .= "<ul>";
foreach ($productIDs as $productID) {
$ID = $productID['product_id'];
$productName_sql = "SELECT name FROM `" . $wpdb->prefix . "product_list` WHERE `id` = '" . $ID . "'";
$productName = $wpdb->get_var($productName_sql);
$output .= "<li><a class='productlink' href='" . wpsc_product_url($ID, $option['id']) . "'>" . $productName . "</a></li>";
}
//end foreach
$output .= "</ul>";
}
//end if productsIDs
}
//end if get_option
}
//end else
$output .= "</li>";
}
$output .= "</ul>";
}
$output .= "</div>";
}
if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 3) {
if (get_option('show_categorybrands') == 1) {
$output .= "<ul class='PeBrands branddisplay' style='display: none;'>";
} else {
$output .= "<ul class='PeBrands branddisplay'>";
}
//$output ='';
$brands = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_brands` WHERE `active`='1' ORDER BY `order` ASC", ARRAY_A);
if ($brands != null) {
foreach ($brands as $option) {
$output .= "<li><a class='categorylink' href='" . get_option('product_list_url') . $seperator . "brand=" . $option['id'] . "'>" . stripslashes($option['name']) . "</a></li>";
}
}
//$output .= $output;
$output .= "</ul>";
}
$output .= "</div>";
//.........这里部分代码省略.........