Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: [Waiting for user confirmation] WordPress Archive WooCommerce if showing Product Categories

$
0
0

Hi Luoy,

On the right sidebar on

klepbankonline.nl

you can see the 'filters'. Each webshop today mostly has some kind of filters to narrow down product results/archives.

And thank you! Because the " is_filtered " is the conditional tag I was looking for! In the "widget logic" plugin you can really easy use conditional tags like this, so that's how I tested it. And indeed a widget with the " is_filtered " conditional tag a test-widget only was visible when I filtered some products, so not on the initial load of the homepage (which is archive-product.php).

So… I probably can use this conditional tag also the other way around like "

!  is_filtered

" to include an other template for the initial load of homepage/archive-product.php instead of showing the TVC-toolset archive of products.

For that I tried to change the archive-product.php, and included an 'if else' statement.

<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive.
 *
 * Override this template by copying it to yourtheme/woocommerce/archive-product.php
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */
get_header(); ?>

<?php if ( ! is_filtered() ) {

	get_template( '../page.php' );

} // end if

else {
	
		/**
		 * woocommerce_before_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
		 * @hooked woocommerce_breadcrumb - 20
		 */

		<?php do_action('woocommerce_before_main_content'); ?>
	

		if ( apply_filters( 'woocommerce_show_page_title', true ) ) { 

		<div class="title-description">
			<header>
				<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
			</header>

		<?php do_action( 'woocommerce_archive_description' ); ?>
		</div> <!-- end .title-description -->

		} // end if

		if ( have_posts() ) { 
			
				/**
				 * woocommerce_before_shop_loop hook
				 *
				 * @hooked woocommerce_result_count - 20
				 * @hooked woocommerce_catalog_ordering - 30
				 */
				<?php do_action( 'woocommerce_before_shop_loop' ); ?>
			

			<?php woocommerce_product_loop_start(); ?>

				<?php woocommerce_product_subcategories(); ?>

				<?php while ( have_posts() ) : the_post(); ?>

					<?php woocommerce_get_template_part( 'content', 'product' ); ?>

				<?php endwhile; // end of the loop. ?>

			<?php woocommerce_product_loop_end(); ?>

			<?php
				/**
				 * woocommerce_after_shop_loop hook
				 *
				 * @hooked woocommerce_pagination - 10
				 */
				do_action( 'woocommerce_after_shop_loop' );
			?>
		
		}

		elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) {

			woocommerce_get_template( 'loop/no-products-found.php' );

		}

	<?php
		/**
		 * woocommerce_after_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
		 */
		do_action('woocommerce_after_main_content');
	?>
	
}
	
<?php get_footer();

But all the time I get errors on the screen which you can see on my staging site:

http://webwinkels001.staging.wpengine.com/

.

It probably has something to do with the way of writing down PHP, using the normal or alternative syntax. Since I'm not used to write PHP I have to take a deeper look here what I am doing wrong here. Can you confirm this is the right modifaction I need to make, and maybe you see what I am doing wrong with the PHP in here?

Kind regards,

Willem


Viewing all articles
Browse latest Browse all 20145

Trending Articles