Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin uses get_index_template() which returns nothing using a Mythic based theme. #81

Open
david-graham opened this issue Sep 22, 2019 · 1 comment

Comments

@david-graham
Copy link

I'm using the latest public release of the WP E-Commerce plugin and am trying to rewrite an old theme using Mythic as a base.

The plugin uses get_index_template() and get_query_template() which, as far as I can tell, return nothing using a Mythic theme.

This is the error:

Warning: include(): Filename cannot be empty in C:\Development\bookstore\wp-content\plugins\wp-e-commerce\wpsc-components\theme-engine-v1\helpers\page.php on line 1039

Warning: include(): Failed opening '' for inclusion (include_path='.;C:\php\pear') in C:\Development\bookstore\wp-content\plugins\wp-e-commerce\wpsc-components\theme-engine-v1\helpers\page.php on line 1039

This is the WP E-Commerce function in question:

// Template tags
function wpsc_all_products_on_page(){

	if ( is_404() ) {
		return;
	}

	global $wp_query,$wpsc_query;
	do_action('wpsc_swap_the_template');
	$products_page_id = wpsc_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' );
		}

		// Attempt to use the [productspage]'s custom page template as a higher priority than the normal page.php template
		if ( false !== $productspage_page_template = get_post_meta($products_page_id, '_wp_page_template', true) )
			array_push( $templates, $productspage_page_template );

		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;
	}
}

I'm going to attempt a workaround similar to https://www.sean-barton.co.uk/2011/08/wp-ecommerce-template-redirect/ and perhaps it can be added to the Plugin Support section on the wiki.

@david-graham
Copy link
Author

I also noticed while working on a workaround that Hybrid\Template\hierarchy returns an empty array on product archive and single product pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant