<?php else: ?> 
							<div class="item_no_image">
								<a href="<?php echo wpsc_the_product_permalink(); ?>">
								<span>No Image Available</span>
								</a>
							</div>
						<?php endif; ?> 
					</div>
					<?php endif; ?> 
		
					<div class="producttext">
						<h2 class="prodtitles"><span><?php echo wpsc_the_product_title(); ?></span><?php echo wpsc_edit_the_product_link(); ?></h2>
							<?php				
								do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
							?>
						<div class="wpsc_description"><?php echo wpsc_the_product_description(); ?></div>
		
						<?php
							do_action('wpsc_product_addons', wpsc_the_product_id());
						?>
						<?php if(wpsc_the_product_additional_description()) : ?>
						<div class="single_additional_description">
            <?php
							$value = '';
							$the_addl_desc = wpsc_the_product_additional_description();
							if( is_serialized($the_addl_desc) ) {
								$addl_descriptions = @unserialize($the_addl_desc);
							} else {
								$addl_descriptions = array('addl_desc', $the_addl_desc);
							}
							
		
					<div class="producttext">
						<h2 class="prodtitles"><span><?php 
    echo wpsc_the_product_title();
    ?>
</span><?php 
    echo wpsc_edit_the_product_link();
    ?>
</h2>
							<?php 
    do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
    ?>
						
						
						<div class="wpsc_description"><?php 
    echo wpsc_the_product_description();
    ?>
</div>
		
						<?php 
    do_action('wpsc_product_addons', wpsc_the_product_id());
    ?>
						<?php 
    if (wpsc_the_product_additional_description()) {
        ?>
						<div class="single_additional_description">
            <?php 
        $value = '';
        $the_addl_desc = wpsc_the_product_additional_description();
        if (is_serialized($the_addl_desc)) {
            $addl_descriptions = @unserialize($the_addl_desc);
				<?php else: ?> 
					<div class="item_no_image">
						<a href="<?php echo wpsc_the_product_permalink(); ?>">
						<span>No Image Available</span>
						</a>
					</div>
				<?php endif; ?> 
				
					
				<?php if(get_option('show_images_only') != 1): ?>
					<div class="grid_product_info">
						<div class="product_text">
							<strong><?php echo wpsc_the_product_title(); ?></strong>
							
						<?php if((wpsc_the_product_description() != '') && (get_option('display_description') == 1)): ?>
							<p class='griddescription'><?php echo wpsc_the_product_description(); ?></p>
						<?php endif; ?>
							
							<br/>
							<span class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span>Price: 
							
						<?php if(get_option('display_moredetails') == 1) : ?>
							<br />
							<a href='<?php echo wpsc_the_product_permalink(); ?>'>More Details</a>
						<?php endif; ?> 
						</div>
					</div>
					<div class="grid_more_info">
						<form class='product_form'  enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
							<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
							<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * 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));
    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;
    $show_discount = isset($instance['show_discount']) ? (bool) $instance['show_discount'] : false;
    $show_old_price = isset($instance['show_old_price']) ? (bool) $instance['show_old_price'] : false;
    $args = array('post_type' => 'wpsc-product', 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'posts_per_page' => $number, 'no_found_rows' => true);
    add_filter('posts_join', '_wpsc_filter_special_widget_join');
    add_filter('posts_where', '_wpsc_filter_special_widget_where');
    $special_products = new WP_Query($args);
    remove_filter('posts_join', '_wpsc_filter_special_widget_join');
    remove_filter('posts_where', '_wpsc_filter_special_widget_where');
    if (!$special_products->post_count) {
        echo apply_filters('wpsc_specials_widget_no_items_message', __('We currently have no items on special.', 'wp-e-commerce'));
        return;
    }
    $product_ids = array();
    while ($special_products->have_posts()) {
        $special_products->the_post();
        ?>
		<h4><strong><a class="wpsc_product_title" href="<?php 
        echo esc_url(wpsc_product_url(wpsc_the_product_id(), false));
        ?>
"><?php 
        echo esc_html(wpsc_the_product_title());
        ?>
</a></h4></strong>

		<?php 
        if ($show_description) {
            ?>
			<div class="wpsc-special-description">
				<?php 
            echo wpsc_the_product_description();
            ?>
			</div>
		<?php 
        }
        // close show description
        if (!in_array(wpsc_the_product_id(), $product_ids)) {
            $product_ids[] = wpsc_the_product_id();
            $has_children = wpsc_product_has_children(get_the_ID());
            $width = get_option('product_image_width');
            $height = get_option('product_image_height');
            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 esc_url(wpsc_the_product_permalink());
                    ?>
"><img class="product_image" id="product_image_<?php 
                    echo esc_attr(wpsc_the_product_id());
                    ?>
" alt="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" title="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" src="<?php 
                    echo esc_url(wpsc_the_product_thumbnail($width, $height));
                    ?>
"/></a>
				<?php 
                } else {
                    ?>
					<a href="<?php 
                    esc_url(wpsc_the_product_permalink());
                    ?>
"><img class="no-image" id="product_image_<?php 
                    echo esc_attr(wpsc_the_product_id());
                    ?>
" alt="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" title="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" src="<?php 
                    echo esc_url(WPSC_CORE_THEME_PATH . '/wpsc-images/noimage.png');
                    ?>
" width="<?php 
                    echo esc_attr($width);
                    ?>
" height="<?php 
                    echo esc_attr($height);
                    ?>
" /></a>
				<?php 
                }
                ?>
				<br />
			<?php 
            }
            // close show thumbnails
            ?>
			<div id="special_product_price_<?php 
            echo esc_attr(wpsc_the_product_id());
            ?>
">
				<?php 
            wpsc_the_product_price_display(array('output_old_price' => $show_old_price, 'output_you_save' => $show_discount));
            ?>
			</div><br />
			<?php 
        }
    }
    wp_reset_postdata();
}
    function wpsc_gold_shpcrt_ajax($id)
    {
        global $wpdb;
        if (isset($_POST) && !empty($_POST)) {
            if (isset($_POST['wpsc_live_search']) && $_POST['wpsc_live_search'] == true && (get_option('show_live_search') == 1 || true == $_POST['wpsc_search_widget']) && !empty($_POST['product_search'])) {
                $keyword = $_POST['product_search'];
                $output = "<ul>";
                if (version_compare(WPSC_VERSION, '3.8', '<')) {
                    $search_sql = gold_shpcrt_search_sql($keyword);
                    $product_list = $wpdb->get_results("SELECT DISTINCT `" . WPSC_TABLE_PRODUCT_LIST . "`.* FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `" . WPSC_TABLE_PRODUCT_LIST . "`.`active`='1' {$search_sql} ORDER BY `" . WPSC_TABLE_PRODUCT_LIST . "`.`name` ASC", ARRAY_A);
                    if ($product_list != null) {
                        foreach ($product_list as $product) {
                            //filter out the HTML, otherwise we get partial tags and everything breaks
                            $product['description'] = wp_kses($product['description'], false);
                            // shorten the description;
                            if (strlen($product['description']) > 68) {
                                $product_description = substr($product['description'], 0, 68) . "...";
                            } else {
                                $product_description = $product['description'];
                            }
                            //generate the HTML
                            $output .= "<li>\n\r";
                            $output .= "\t<a href='" . wpsc_product_url($product['id']) . "'>\n\r";
                            if ($product['image'] != '') {
                                $output .= "\t\t\t\t<img class='live-search-image' src='index.php?productid=" . $product['id'] . "&amp;width=50&amp;height=50'>\n\r";
                            } else {
                                $output .= "\t\t\t\t<img class='live-search-image' src='" . get_option('siteurl') . "/wp-content/plugins/" . WPSC_DIR_NAME . "/no-image-uploaded.gif' style='height: 50px; width: 50px;'>\n\r";
                            }
                            $output .= "\t\t\t\t<div class='live-search-text'>\n\r";
                            $output .= "\t\t\t\t\t<strong>" . $product['name'] . "</strong>\n\r";
                            $output .= "\t\t\t\t\t<div class='description'>" . stripslashes($product_description) . "</div>\n\r";
                            $output .= "\t\t\t\t</div>\n\r";
                            $output .= "\t\t    <br clear='both' />\n\r";
                            $output .= "\t\t</a>\n\r";
                            $output .= "</li>\n\r";
                        }
                    }
                } else {
                    wpsc_gc_start_search_query();
                    echo '<ul>';
                    while (wpsc_have_products()) {
                        wpsc_the_product();
                        ?>
					<li>
						<a style="clear:both;" href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<?php 
                        if (wpsc_the_product_thumbnail()) {
                            ?>
								<img class="live-search-image" alt="<?php 
                            echo wpsc_the_product_title();
                            ?>
" src="<?php 
                            echo wpsc_the_product_thumbnail(50, 50, 0, 'live-search');
                            ?>
" />
							<?php 
                        } else {
                            ?>
								<img class="live-search-image" alt="No Image" title="<?php 
                            echo wpsc_the_product_title();
                            ?>
" src="<?php 
                            echo WPSC_CORE_THEME_URL;
                            ?>
wpsc-images/noimage.png" style="width:50px; height:50px;" />
							<?php 
                        }
                        ?>
							<div class="live-search-text">
								<strong><?php 
                        echo wpsc_the_product_title();
                        ?>
</strong>
								<div class="description">
									<?php 
                        echo wpsc_the_product_description();
                        ?>
								</div>
							</div>
						</a>
					</li>	
					<?php 
                    }
                    echo '</ul>';
                    exit;
                }
                $output .= "</ul>";
                if (!empty($product_list)) {
                    $_SESSION['live_search_results'] = $product_list;
                }
                exit($output);
            }
        }
        if (isset($_POST['affiliate']) && $_POST['affiliate'] == true) {
            if (!function_exists('affiliate_text')) {
                function affiliate_text($id, $user)
                {
                    $output = "<a target='_blank' title='Your Shopping Cart' href='" . get_option('siteurl') . "/?action=affiliate&p={$id}&user_id=" . $user . "&height=400&width=600' class='thickbox'><img src='" . WPSC_URL . "/" . $images_dir . "/buynow.jpg'></a>";
                    return $output;
                }
            }
            $id = $_POST['prodid'];
            $product = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE id='{$id}' LIMIT 1", ARRAY_A);
            $product = $product[0];
            $link = affiliate_text($id, $_POST['uid']);
            echo "<textarea class='affiliate_text' onclick='this.select();' >{$link}</textarea>";
            exit;
        }
        if (isset($_POST['log_affiliate']) && $_POST['log_affiliate'] == true) {
            $uid = $_POST['uid'];
            $amount = $_POST['amount'];
            $product = $wpdb->query("UPDATE {$wpdb->prefix}wpsc_affiliates SET paid=paid+{$amount}  WHERE user_id='{$uid}'");
            echo "uid=" . $uid;
            exit;
        }
    }
Exemple #6
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();
    }
}
/**
 * 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 
                echo wpsc_the_product_price();
                ?>
				</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();
    }
}