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;
    }
    $regular_price = wpsc_calculate_price($product_id, $variations, false);
    $sale_price = wpsc_calculate_price($product_id, $variations, true);
    switch ($type) {
        case "amount":
            return $regular_price - $sale_price;
            break;
        default:
            if ($regular_price == 0) {
                return 0;
            } else {
                return number_format(($regular_price - $sale_price) / $regular_price * 100, 2);
            }
    }
}
Example #2
0
/**
 * update_product_page_price function, used through ajax with variations
 * No parameters, returns nothing
 */
function wpsc_update_product_price()
{
    global $wpdb, $wpsc_cart;
    $from = '';
    $change_price = true;
    foreach ((array) $_POST['variation'] as $variation) {
        if (is_numeric($variation)) {
            $variations[] = (int) $variation;
        }
        if ($variation == 0) {
            $from = ' from ';
            $from = apply_filters('wpsc_product_variation_text', $from);
            $change_price = false;
        }
    }
    do_action('wpsc_update_variation_product', (int) $_POST['product_id'], $variations);
    $pm = $_POST['pm'];
    $stock = wpsc_check_variation_stock_availability((int) $_POST['product_id'], $variations);
    if (is_numeric($stock) && $stock == 0) {
        echo "product_msg=\"" . __('Sorry, but this variation is out of stock.', 'wpsc') . "\";\n";
        echo "variation_msg=\"" . __('Produto não disponível', 'wpsc') . "\";\n";
        echo "variation_status= false \n";
    } else {
        echo "variation_msg=\"" . __('Product in stock', 'wpsc') . "\";\n";
        echo "variation_status= true \n";
    }
    echo "product_id=" . (int) $_POST['product_id'] . ";\n";
    if ($change_price) {
        echo "old_price=\"" . wpsc_currency_display(wpsc_calculate_price((int) $_POST['product_id'], $variations, false), array('display_as_html' => false)) . "\";\n";
        echo "numeric_old_price=\"" . number_format(wpsc_calculate_price((int) $_POST['product_id'], $variations, false)) . "\";\n";
        echo "you_save=\"" . wpsc_currency_display(wpsc_you_save(array('product_id' => (int) $_POST['product_id'], 'type' => 'amount', 'variations' => $variations)), array('display_as_html' => false)) . "! (" . wpsc_you_save(array('product_id' => (int) $_POST['product_id'], 'variations' => $variations)) . "%)\";\n";
        echo "price=\"" . $from . wpsc_currency_display(wpsc_calculate_price((int) $_POST['product_id'], $variations, true), array('display_as_html' => false)) . "\";\n";
        echo "numeric_price=\"" . number_format(wpsc_calculate_price((int) $_POST['product_id'], $variations, true)) . "\";\n";
    }
    exit;
}
								
								<?php 
    if (wpsc_product_is_donation()) {
        ?>
									<label for="donation_price_<?php 
        echo wpsc_the_product_id();
        ?>
"><?php 
        _e('Donation', 'wpsc');
        ?>
: </label>
									<input type="text" id="donation_price_<?php 
        echo wpsc_the_product_id();
        ?>
" name="donation_price" value="<?php 
        echo wpsc_calculate_price(wpsc_the_product_id());
        ?>
" size="6" />
								<?php 
    } else {
        ?>
									<?php 
        wpsc_the_product_price_display();
        ?>
									 <!-- multi currency code -->
                                    <?php 
        if (wpsc_product_has_multicurrency()) {
            ?>
	                                    <?php 
            echo wpsc_display_product_multicurrency();
            ?>
Example #4
0
function wpsc_generate_product_feed()
{
    global $wpdb, $wp_query, $post;
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $siteurl = get_option('siteurl');
    // Allow limiting
    if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
        $limit = "LIMIT " . $_GET['limit'] . "";
    } else {
        $limit = '';
    }
    $selected_category = '';
    $selected_product = '';
    if (isset($_GET['product_id']) && is_numeric($_GET['product_id'])) {
        $args[] = array('post__in' => $_GET['product_id']);
    } elseif (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) {
        $args[] = array('cat' => $_GET['category_id']);
    }
    $args['post_type'] = 'wpsc-product';
    $args['posts_per_page'] = 999;
    $products = query_posts($args);
    $self = get_option('siteurl') . "/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}";
    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 ($products as $post) {
        setup_postdata($post);
        $purchase_link = wpsc_product_url($post->ID);
        $output .= "    <item>\n\r";
        if ($google_checkout_note) {
            $output .= "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
        }
        $output .= "      <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
        $output .= "      <link>{$purchase_link}</link>\n\r";
        $output .= "      <description><![CDATA[" . get_the_content() . "]]></description>\n\r";
        $output .= "      <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
        $output .= "      <guid>{$purchase_link}</guid>\n\r";
        $image_link = FALSE;
        if (has_post_thumbnail($post->ID)) {
            $post_thumbnail_id = get_post_thumbnail_id($post->ID);
            $src = wp_get_attachment_image_src($post_thumbnail_id, 'large');
            $image_link = $src[0];
        }
        if ($image_link !== FALSE) {
            if ($_GET['xmlformat'] == 'google') {
                $output .= "      <g:image_link>{$image_link}</g:image_link>\n\r";
            } else {
                $output .= "      <enclosure url='{$image_link}' />\n\r";
            }
        }
        $price = wpsc_calculate_price($post->ID);
        $children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
        foreach ($children as $child) {
            $child_price = wpsc_calculate_price($child->ID);
            if ($price == 0 && $child_price > 0) {
                $price = $child_price;
            } else {
                if ($child_price > 0 && $child_price < $price) {
                    $price = $child_price;
                }
            }
        }
        if ($_GET['xmlformat'] == 'google') {
            $output .= "      <g:price>" . $price . "</g:price>\n\r";
            $product_meta = get_post_meta($post->ID, '_wpsc_product_metadata', true);
            foreach (array_keys($product_meta) as $meta_key) {
                if (stripos($meta_key, 'g:') === 0) {
                    $google_elements[$meta_key] = $product_meta[$meta_key];
                }
            }
            $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>" . $price . "</product:price>\n\r";
        }
        $output .= "    </item>\n\r";
    }
    $output .= "  </channel>\n\r";
    $output .= "</rss>";
    echo $output;
    exit;
}
Example #5
0
/**
 * update_product_page_price function, used through ajax with variations
 * No parameters, returns nothing
 */
function wpsc_update_product_price()
{
    $from = '';
    $change_price = true;
    $product_id = (int) $_POST['product_id'];
    $variations = array();
    $response = array('product_id' => $product_id, 'variation_found' => false);
    if (!empty($_POST['variation'])) {
        foreach ($_POST['variation'] as $variation) {
            if (is_numeric($variation)) {
                $variations[] = (int) $variation;
            }
        }
        do_action('wpsc_update_variation_product', $product_id, $variations);
        $stock = wpsc_check_variation_stock_availability($product_id, $variations);
        if ($stock !== false) {
            $response['variation_found'] = true;
            if ($stock === 0) {
                $response += array('product_msg' => __('Sorry, but this variation is out of stock.', 'wpsc'), 'variation_msg' => __('Variation not in stock', 'wpsc'), 'stock_available' => false);
            } else {
                $response += array('variation_msg' => __('Product in stock', 'wpsc'), 'stock_available' => true);
            }
            if ($change_price) {
                $old_price = wpsc_calculate_price($product_id, $variations, false);
                $you_save_amount = wpsc_you_save(array('product_id' => $product_id, 'type' => 'amount', 'variations' => $variations));
                $you_save_percentage = wpsc_you_save(array('product_id' => $product_id, 'variations' => $variations));
                $price = wpsc_calculate_price($product_id, $variations, true);
                $response += array('old_price' => wpsc_currency_display($old_price, array('display_as_html' => false)), 'numeric_old_price' => (double) number_format($old_price), 'you_save' => wpsc_currency_display($you_save_amount, array('display_as_html' => false)) . "! (" . $you_save_percentage . "%)", 'price' => $from . wpsc_currency_display($price, array('display_as_html' => false)), 'numeric_price' => (double) number_format($price));
            }
        }
    }
    echo json_encode($response);
    exit;
}
  <?php 
    if (wpsc_product_is_donation()) {
        ?>
    <label for="donation_price_<?php 
        echo $product_id;
        ?>
"><?php 
        _e('Donation', ETHEME_DOMAIN);
        ?>
: </label>
    <input type="text" id="donation_price_<?php 
        echo $product_id;
        ?>
" name="donation_price"
           value="<?php 
        echo wpsc_calculate_price($product_id);
        ?>
" size="6"/>
  <?php 
    }
    ?>

  <input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
  <input type="hidden" value="<?php 
    echo $product_id;
    ?>
" name="product_id"/>

  <hr>

  <div class="addto-container">
Example #7
0
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);
            }
    }
}
Example #8
0
function wpsc_generate_product_feed()
{
    global $wpdb, $wp_query, $post;
    set_time_limit(0);
    // Don't build up a huge posts cache for the whole store - http://code.google.com/p/wp-e-commerce/issues/detail?id=885
    // WP 3.3+ only
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(true);
    }
    $chunk_size = apply_filters('wpsc_productfeed_chunk_size', 50);
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $selected_category = '';
    $selected_product = '';
    $args = array('post_type' => 'wpsc-product', 'numberposts' => $chunk_size, 'offset' => 0, 'cache_results' => false);
    $args = apply_filters('wpsc_productfeed_query_args', $args);
    $self = site_url("/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}");
    header("Content-Type: application/xml; charset=UTF-8");
    header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
    echo "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
    echo "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
    $google_checkout_note = false;
    if ($_GET['xmlformat'] == 'google') {
        echo ' 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 {
        echo ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
    }
    echo ">\n\r";
    echo "  <channel>\n\r";
    echo "    <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
    echo "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
    echo "    <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
    echo "    <generator>WP e-Commerce Plugin</generator>\n\r";
    echo "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
    $products = get_posts($args);
    while (count($products)) {
        foreach ($products as $post) {
            setup_postdata($post);
            $purchase_link = wpsc_product_url($post->ID);
            echo "    <item>\n\r";
            if ($google_checkout_note) {
                echo "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
            }
            echo "      <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
            echo "      <link>{$purchase_link}</link>\n\r";
            echo "      <description><![CDATA[" . apply_filters('the_content', get_the_content()) . "]]></description>\n\r";
            echo "      <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
            echo "      <guid>{$purchase_link}</guid>\n\r";
            $image_link = wpsc_the_product_thumbnail();
            if ($image_link !== FALSE) {
                if ($_GET['xmlformat'] == 'google') {
                    echo "      <g:image_link>{$image_link}</g:image_link>\n\r";
                } else {
                    echo "      <enclosure url='{$image_link}' />\n\r";
                }
            }
            $price = wpsc_calculate_price($post->ID);
            $currargs = array('display_currency_symbol' => false, 'display_decimal_point' => true, 'display_currency_code' => false, 'display_as_html' => false);
            $price = wpsc_currency_display($price, $currargs);
            $children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
            foreach ($children as $child) {
                $child_price = wpsc_calculate_price($child->ID);
                if ($price == 0 && $child_price > 0) {
                    $price = $child_price;
                } else {
                    if ($child_price > 0 && $child_price < $price) {
                        $price = $child_price;
                    }
                }
            }
            if ($_GET['xmlformat'] == 'google') {
                echo "      <g:price>" . $price . "</g:price>\n\r";
                $google_elements = array();
                $product_meta = get_post_custom($post->ID);
                if (is_array($product_meta)) {
                    foreach ($product_meta as $meta_key => $meta_value) {
                        if (stripos($meta_key, 'g:') === 0) {
                            $google_elements[$meta_key] = $meta_value;
                        }
                    }
                }
                $google_elements = apply_filters('wpsc_google_elements', array('product_id' => $post->ID, 'elements' => $google_elements));
                $google_elements = $google_elements['elements'];
                $done_condition = FALSE;
                $done_availability = FALSE;
                $done_weight = FALSE;
                if (count($google_elements)) {
                    foreach ($google_elements as $element_name => $element_values) {
                        foreach ($element_values as $element_value) {
                            echo "      <" . $element_name . ">";
                            echo "<![CDATA[" . $element_value . "]]>";
                            echo "</" . $element_name . ">\n\r";
                        }
                        if ($element_name == 'g:shipping_weight') {
                            $done_weight = TRUE;
                        }
                        if ($element_name == 'g:condition') {
                            $done_condition = TRUE;
                        }
                        if ($element_name == 'g:availability') {
                            $done_availability = true;
                        }
                    }
                }
                if (!$done_condition) {
                    echo "      <g:condition>new</g:condition>\n\r";
                }
                if (!$done_availability) {
                    if (wpsc_product_has_stock()) {
                        $product_availability = "in stock";
                    } else {
                        $product_availability = "out of stock";
                    }
                    echo " <g:availability>{$product_availability}</g:availability>";
                }
                if (!$done_weight) {
                    $wpsc_product_meta = get_product_meta($post->ID, 'product_metadata', true);
                    $weight = apply_filters('wpsc_google_shipping_weight', $wpsc_product_meta['weight'], $post->ID);
                    if ($weight && is_numeric($weight) && $weight > 0) {
                        echo "<g:shipping_weight>{$weight} pounds</g:shipping_weight>";
                    }
                }
            } else {
                echo "      <product:price>" . $price . "</product:price>\n\r";
            }
            echo "    </item>\n\r";
        }
        $args['offset'] += $chunk_size;
        $products = get_posts($args);
    }
    echo "  </channel>\n\r";
    echo "</rss>";
    exit;
}
Example #9
0
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above)
 *
 * Changes made in 3.8 that may affect users:
 *
 * 1. The product title link text does now not have a bold tag, it should be styled via css.
 * 2. <br /> tags have been ommitted. Padding and margins should be applied via css.
 * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class.
 * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class.
 * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output).
 */
function wpsc_specials($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    if (!($number = (int) $instance['number'])) {
        $number = 5;
    }
    $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE;
    $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE;
    $excludes = wpsc_specials_excludes();
    $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number);
    $special_products = query_posts($args);
    $output = '';
    $product_ids[] = array();
    if (count($special_products) > 0) {
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        while (wpsc_have_products()) {
            wpsc_the_product();
            if (!in_array(wpsc_the_product_id(), $product_ids)) {
                $product_ids[] = wpsc_the_product_id();
                if ($show_thumbnails) {
                    if (wpsc_the_product_thumbnail()) {
                        ?>
						<a rel="<?php 
                        echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                        ?>
" href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="product_image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="<?php 
                        echo wpsc_the_product_title();
                        ?>
" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo wpsc_the_product_thumbnail();
                        ?>
"/>
						</a>
				<?php 
                    } else {
                        ?>
							<a href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="no-image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="No Image" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo WPSC_URL;
                        ?>
/wpsc-theme/wpsc-images/noimage.png" width="<?php 
                        esc_attr_e(get_option('product_image_width'));
                        ?>
" height="<?php 
                        esc_attr_e(get_option('product_image_height'));
                        ?>
" />
							</a>
				<?php 
                    }
                    ?>
				<?php 
                }
                // close show thumbnails
                ?>
 
				<br />
				<span id="special_product_price_<?php 
                echo wpsc_the_product_id();
                ?>
">
				<!-- price display -->
				<?php 
                if (wpsc_have_variation_groups()) {
                    while (wpsc_have_variation_groups()) {
                        wpsc_the_variation_group();
                        ?>
								<?php 
                        /** the variation HTML and loop */
                        ?>
								<?php 
                        $variation_outputs = array();
                        ?>
								<?php 
                        while (wpsc_have_variations()) {
                            wpsc_the_variation();
                            ?>
										<?php 
                            $variation_outputs[] = '';
                            $variation_prices[] = wpsc_the_variation_price(true);
                        }
                        // Sort the variations into price order before outputting
                        $data[] = $variation_outputs;
                        $data[] = $variation_prices;
                        array_multisort($data[1], SORT_ASC, SORT_NUMERIC, $data[0], SORT_ASC, SORT_STRING);
                        ?>
						<?php 
                    }
                    echo __('From', 'wpsc') . ' : ' . wpsc_currency_display($data[1][0]);
                    ?>
				<?php 
                } else {
                    ?>
				<?php 
                    echo wpsc_currency_display(wpsc_calculate_price(wpsc_the_product_id(), null, true));
                    ?>
				
				<?php 
                }
                ?>
				</span><br />			
				<strong><a class="wpsc_product_title" href="<?php 
                echo wpsc_product_url(wpsc_the_product_id(), false);
                ?>
"><?php 
                echo wpsc_the_product_title();
                ?>
</a></strong><br /> 
				
				<?php 
                if ($show_description) {
                    ?>
					<div class="wpsc-special-description">
						<?php 
                    echo wpsc_the_product_description();
                    ?>
					</div>									
				<?php 
                }
                // close show description
                ?>
 
			
				<?php 
            }
        }
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        wp_reset_query();
    }
}
 public function send_product()
 {
     if (wpsc_is_single_product()) {
         $product = array();
         while (wpsc_have_products()) {
             wpsc_the_product();
             $product_id = (int) wpsc_the_product_id();
             $product['url'] = (string) wpsc_the_product_permalink();
             $product['product_id'] = $product_id;
             $product['name'] = (string) wpsc_the_product_title();
             $product['image_url'] = (string) wpsc_the_product_image('', '', $product_id);
             if (wpsc_product_has_variations($product_id)) {
                 $price = $this->get_lowest_product_variation_price($product_id);
             } else {
                 $price = wpsc_calculate_price($product_id, false, true);
             }
             $product['price'] = $this->format_price($price);
             if (wpsc_product_has_stock($product_id)) {
                 $product['stock'] = 1;
             } else {
                 $product['stock'] = 0;
             }
             $product['categories'] = array();
             $category_terms = wp_get_product_categories($product_id);
             foreach ($category_terms as $category_term) {
                 $category_path = $category_term;
                 if (!empty($category_path)) {
                     $product['category_name'] = $category_term->name;
                     $product['category_id'] = $category_term->term_id;
                 }
             }
             if (wpsc_product_has_variations($product_id)) {
                 $list_price = $this->get_lowest_product_variation_price($product_id);
             } else {
                 $list_price = wpsc_calculate_price($product_id, false, false);
             }
             $product['list_price'] = $this->format_price($list_price);
         }
         if (!empty($product)) {
             $this->render('sendProduct', array('product' => $product));
         }
     }
 }