Advertisement
Guest User

Untitled

a guest
May 2nd, 2011
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. function wpsc_display_products_page( $query ) {
  2. global $wpdb, $wpsc_query,$wp_query;
  3. remove_filter('the_title','wpsc_the_category_title');
  4.  
  5. // If the data is coming from a shortcode parse the values into the args variable,
  6. // I did it this was to preserve backwards compatibility
  7. if(!empty($query)){
  8. $args['post_type'] = 'wpsc-product';
  9. if(!empty($query['product_id']) && is_array($query['product_id'])){
  10. $args['post__in'] = $query['product_id'];
  11. }elseif(is_string($query['product_id'])){
  12. $args['post__in'] = (array)$query['product_id'];
  13. }
  14. if(!empty($query['old_product_id'])){
  15. $post_id = wpsc_get_the_new_id($query['old_product_id']);
  16. $args['post__in'] = (array)$post_id;
  17. }
  18. if(!empty($query['price']) && 'sale' != $query['price']){
  19. $args['meta_key'] = '_wpsc_price';
  20. $args['meta_value'] = $query['price'];
  21. }elseif(!empty($query['price']) && 'sale' == $query['price']){
  22. $args['meta_key'] = '_wpsc_special_price';
  23. $args['meta_compare'] = '>=';
  24. $args['meta_value'] = '1';
  25. }
  26. if(!empty($query['product_name'])){
  27. $args['pagename'] = $query['product_name'];
  28. }
  29. if(!empty($query['category_id'])){
  30.  
  31. $term = get_term($query['category_id'],'wpsc_product_category');
  32. $id = wpsc_get_meta($query['category_id'], 'category_id','wpsc_old_category');
  33. if( !empty($id)){
  34. $term = get_term($id,'wpsc_product_category');
  35. $args['wpsc_product_category'] = $term->slug;
  36. $args['wpsc_product_category__in'] = $term->term_id;
  37. }else{
  38. $args['wpsc_product_category'] = $term->slug;
  39. $args['wpsc_product_category__in'] = $term->term_id;
  40. }
  41. }
  42. if(!empty($query['category_url_name'])){
  43. $args['wpsc_product_category'] = $query['category_url_name'];
  44. }
  45. if(!empty($query['sort_order'])){
  46. $args['orderby'] = $query['sort_order'];
  47. }
  48. if(!empty($query['order'])){
  49. $args['order'] = $query['order'];
  50. }
  51. if(!empty($query['limit_of_items']) && '1' == get_option('use_pagination')){
  52. $args['posts_per_page'] = $query['limit_of_items'];
  53. }
  54. if(!empty($query['number_per_page']) && '1' == get_option('use_pagination')){
  55. $args['posts_per_page'] = $query['number_per_page'];
  56. }
  57. if( '0' == get_option('use_pagination') ){
  58. $args['nopaging'] = true;
  59. $args['posts_per_page'] = '-1';
  60. }
  61. if(!empty($query['tag'])){
  62. $args['product_tag'] = $query['tag'];
  63. }
  64.  
  65. $temp_wpsc_query = new WP_Query($args);
  66. }
  67. // swap the wpsc_query objects
  68. list( $wp_query, $temp_wpsc_query ) = array( $temp_wpsc_query, $wp_query );
  69. $GLOBALS['nzshpcrt_activateshpcrt'] = true;
  70.  
  71. // Pretty sure this single_product code is legacy...but fixing it up just in case.
  72. // get the display type for the selected category
  73. if(!empty($temp_wpsc_query->query_vars['term']))
  74. $display_type = wpsc_get_the_category_display($temp_wpsc_query->query_vars['term']);
  75. elseif( !empty( $args['wpsc_product_category'] ) )
  76. $display_type = wpsc_get_the_category_display($args['wpsc_product_category']);
  77. else
  78. $display_type = 'default';
  79.  
  80. if ( isset( $_SESSION['wpsc_display_type'] ) )
  81. $display_type = $_SESSION['wpsc_display_type'];
  82.  
  83. ob_start();
  84. if( 'wpsc-product' == $wp_query->post->post_type && !is_archive() && $wp_query->post_count <= 1 )
  85. include( wpsc_get_template_file_path( 'wpsc-single_product.php' ) );
  86. else
  87. wpsc_include_products_page_template($display_type);
  88. $is_single = false;
  89.  
  90. $output = ob_get_contents();
  91. ob_end_clean();
  92. $output = str_replace('\$','$', $output);
  93. list($temp_wpsc_query, $wp_query) = array( $wp_query, $temp_wpsc_query ); // swap the wpsc_query objects back
  94. if ( $is_single == false ) {
  95. $GLOBALS['post'] = $wp_query->post;
  96. }
  97. return $output;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement