Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpsc_display_products_page( $query ) {
- global $wpdb, $wpsc_query,$wp_query;
- remove_filter('the_title','wpsc_the_category_title');
- // If the data is coming from a shortcode parse the values into the args variable,
- // I did it this was to preserve backwards compatibility
- if(!empty($query)){
- $args['post_type'] = 'wpsc-product';
- if(!empty($query['product_id']) && is_array($query['product_id'])){
- $args['post__in'] = $query['product_id'];
- }elseif(is_string($query['product_id'])){
- $args['post__in'] = (array)$query['product_id'];
- }
- if(!empty($query['old_product_id'])){
- $post_id = wpsc_get_the_new_id($query['old_product_id']);
- $args['post__in'] = (array)$post_id;
- }
- if(!empty($query['price']) && 'sale' != $query['price']){
- $args['meta_key'] = '_wpsc_price';
- $args['meta_value'] = $query['price'];
- }elseif(!empty($query['price']) && 'sale' == $query['price']){
- $args['meta_key'] = '_wpsc_special_price';
- $args['meta_compare'] = '>=';
- $args['meta_value'] = '1';
- }
- if(!empty($query['product_name'])){
- $args['pagename'] = $query['product_name'];
- }
- if(!empty($query['category_id'])){
- $term = get_term($query['category_id'],'wpsc_product_category');
- $id = wpsc_get_meta($query['category_id'], 'category_id','wpsc_old_category');
- if( !empty($id)){
- $term = get_term($id,'wpsc_product_category');
- $args['wpsc_product_category'] = $term->slug;
- $args['wpsc_product_category__in'] = $term->term_id;
- }else{
- $args['wpsc_product_category'] = $term->slug;
- $args['wpsc_product_category__in'] = $term->term_id;
- }
- }
- if(!empty($query['category_url_name'])){
- $args['wpsc_product_category'] = $query['category_url_name'];
- }
- if(!empty($query['sort_order'])){
- $args['orderby'] = $query['sort_order'];
- }
- if(!empty($query['order'])){
- $args['order'] = $query['order'];
- }
- if(!empty($query['limit_of_items']) && '1' == get_option('use_pagination')){
- $args['posts_per_page'] = $query['limit_of_items'];
- }
- if(!empty($query['number_per_page']) && '1' == get_option('use_pagination')){
- $args['posts_per_page'] = $query['number_per_page'];
- }
- if( '0' == get_option('use_pagination') ){
- $args['nopaging'] = true;
- $args['posts_per_page'] = '-1';
- }
- if(!empty($query['tag'])){
- $args['product_tag'] = $query['tag'];
- }
- $temp_wpsc_query = new WP_Query($args);
- }
- // swap the wpsc_query objects
- list( $wp_query, $temp_wpsc_query ) = array( $temp_wpsc_query, $wp_query );
- $GLOBALS['nzshpcrt_activateshpcrt'] = true;
- // Pretty sure this single_product code is legacy...but fixing it up just in case.
- // get the display type for the selected category
- if(!empty($temp_wpsc_query->query_vars['term']))
- $display_type = wpsc_get_the_category_display($temp_wpsc_query->query_vars['term']);
- elseif( !empty( $args['wpsc_product_category'] ) )
- $display_type = wpsc_get_the_category_display($args['wpsc_product_category']);
- else
- $display_type = 'default';
- if ( isset( $_SESSION['wpsc_display_type'] ) )
- $display_type = $_SESSION['wpsc_display_type'];
- ob_start();
- if( 'wpsc-product' == $wp_query->post->post_type && !is_archive() && $wp_query->post_count <= 1 )
- include( wpsc_get_template_file_path( 'wpsc-single_product.php' ) );
- else
- wpsc_include_products_page_template($display_type);
- $is_single = false;
- $output = ob_get_contents();
- ob_end_clean();
- $output = str_replace('\$','$', $output);
- list($temp_wpsc_query, $wp_query) = array( $wp_query, $temp_wpsc_query ); // swap the wpsc_query objects back
- if ( $is_single == false ) {
- $GLOBALS['post'] = $wp_query->post;
- }
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement