wpsc_swap_the_template

Located in: theme.functions.php

Functions that call this hook: wpsc_all_products_on_page()
Arguments Accepted: none
Version Introduced: 3.8

Description: This function wpsc_all_products_on_page() is triggered by the template_redirect hook. The wpsc_swap_the_template action is called from that function it is used to replace the templates for each type of page (single product, taxonomy page) etc

Code in context:
[php firstline=”1047″ highlight=”1049″]
function wpsc_all_products_on_page(){
global $wp_query,$wpsc_query;
do_action(‘wpsc_swap_the_template’);
$products_page_id = wpec_get_the_post_id_by_shortcode(‘[productspage]’);
$term = get_query_var( ‘wpsc_product_category’ );
$tax_term = get_query_var (‘product_tag’ );
$obj = $wp_query->get_queried_object();

$id = isset( $obj->ID ) ? $obj->ID : null;

if( get_query_var( ‘post_type’ ) == ‘wpsc-product’ || $term || $tax_term || ( $id == $products_page_id )){

$templates = array();

if ( $term && ! is_single() ) {
array_push( $templates, "taxonomy-wpsc_product_category-{$term}.php", ‘taxonomy-wpsc_product_category.php’ );
}

if ( $tax_term && ! is_single() ) {
array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", ‘taxonomy-product_tag.php’ );
}

array_push( $templates, ‘page.php’, ‘single.php’ );

if ( is_single() )
array_unshift( $templates, ‘single-wpsc-product.php’ );

// have to pass ‘page’ as the template type. This is lame, btw, and needs a rewrite in 4.0
if ( ! $template = get_query_template( ‘page’, $templates ) )
$template = get_index_template();

add_filter( ‘thesis_custom_loop’, ‘wpsc_thesis_compat’ );

include( $template );
exit;
}
}
add_action(‘template_redirect’, ‘wpsc_all_products_on_page’);
[/php]