Help needed Wordpress / Woocommerce

Associate
Joined
30 Nov 2010
Posts
2,276
Location
UK
Hi,

Really hope someone can help because this is driving me mad, I have made a website with Wordpress and Woocommerce.

I am trying to add a product filter that will arrange items by brand using the "Woocommerce AJAX Product filter" I have everything installed and it does appear on my page, but when clicking a filter the page does not filter, however if I go to another page and return it will show just the filtered results.

I think this is a common problem with the plug-in as the author has mentioned it within the documentation but it's not that clear and so far I have had no luck.

This is what he says:

URL changes but products list are not refreshed/ All products are show, filters don't make a change:

It seems your shop theme is missing some standard WooCommerce actions and hooks so plugin can't recognize page contents to refresh.
This plugin uses "woocommerce_before_shop_loop" and "woocommerce_after_shop_loop" actions to wrap products.

It means that you should print products between these two actions.

By following WooCommerce templating rules, these two action should be located at:
woocommerce/archive-product.php


There is a fallback for non-standard themes:
Some themes are not build with best practices so we provided a fallback:
These themes print products in an unordered list like this:

<ul class="products">
<li>Product 1</li>
<li>Product 2</li>
<li>Product 3</li>
</ul>

This is also a rule for WooCommerce templating. (having a ul with products class)
If you don't know how to fix your theme just send a message to your theme support team and they can do it in a few minutes.

This plugin supports another way to refresh products:
Wrap products in a span tag with codenegar-shop-loop-wrapper class like this:

<span class="codenegar-shop-loop-wrapper">
Product 1
Product 2
Product 3
</span>


I have tried editing the archive-product.php but there are no products listed and can't see where to change the UL list to his custom span class.

Has anyone got any ideas? I would really appreciate some help on this. I am doing this site free of charge for a friend so can't offer any money I'm afraid.

I have tried asking the Author of the plugin but looking at previous support tickets they can take up to 2 weeks to reply and the theme auther does not want to know as it's a third party plug-in.
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
I am using Woocommerce 2.0.18

This is what my archive-product.php that's within theme/woocommerce2 looks like:

<?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
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

get_header('shop'); ?>
<div id="contentarea" class="row">
<?php if (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'template-leftsidebar.php') { ?>
<aside class="grid_3 left-sidebar">
<?php
(get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true)) ? $sidebar = get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true) : $sidebar = "default-sidebar";
generated_dynamic_sidebar_th($sidebar); ?>
</aside>
<?php } ?>
<div class="<?php echo (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'default')? 'grid_12':'grid_9'; ?>">
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action('woocommerce_before_main_content');
?>

<!--<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>-->
<?php if ( is_tax() && get_query_var( 'paged' ) == 0 ) : ?>
<?php echo '<div class="term-description">' . wpautop( wptexturize( term_description() ) ) . '</div>'; ?>
<?php elseif ( ! is_search() && get_query_var( 'paged' ) == 0 && ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
<?php echo '<div class="page-description">' . apply_filters( 'the_content', $shop_page->post_content ) . '</div>'; ?>
<?php endif; ?>


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

<?php if ( have_posts() ) : ?>

<?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(); ?>

<div class="clear"></div>

<?php
//product sorter

/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>

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

<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

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

<?php endif; ?>

<?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
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
//do_action('woocommerce_sidebar');
?>


</div>
<?php if (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'template-rightsidebar.php') { ?>
<aside class="grid_3 right-sidebar">
<?php
(get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true)) ? $sidebar = get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true) : $sidebar = "default-sidebar";
generated_dynamic_sidebar_th($sidebar); ?>
</aside>
<?php } ?>
<div class="clear"></div>


<?php get_footer('shop'); ?>
 
Last edited:
Associate
Joined
16 Mar 2013
Posts
396
The start of the loop is under woocommerce/templates/loop/loop-start.php but has the class of products already so not sure what he's on about.

For the page to not reload is an issue with the jQuery and AJAX rather then WooCommerce. When was the plugin developed as I see this quite often with older plugins using AJAX, they work but the output isn't updated.

There's so many up to date plugins out there, I tend to just move on and find another rather then try and fix it.
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
Hi, thanks for taking a look. The plug-in is current and was last updated 3-9-13. I would be happy to use something else if it had the same features but I can't find anything.
I was having a play around and can actually get it working with the filter updating the page, I done this by adding the span class he mentioned "<span class="codenegar-shop-loop-wrapper"

I have highlighted in red where I inserted it in the code below. The only problem I am having is the filtered range is duplicated so all the products within the filtered range show up twice. I am hoping I could get this working without duplicating the products if I could work out where to insert the span class.

<?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
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

get_header('shop'); ?>
<div id="contentarea" class="row">
<?php if (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'template-leftsidebar.php') { ?>
<aside class="grid_3 left-sidebar">
<?php
(get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true)) ? $sidebar = get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true) : $sidebar = "default-sidebar";
generated_dynamic_sidebar_th($sidebar); ?>
</aside>
<?php } ?>
<div class="<?php echo (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'default')? 'grid_12':'grid_9'; ?>">
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action('woocommerce_before_main_content');
?>

<!--<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>-->
<?php if ( is_tax() && get_query_var( 'paged' ) == 0 ) : ?>
<?php echo '<div class="term-description">' . wpautop( wptexturize( term_description() ) ) . '</div>'; ?>
<?php elseif ( ! is_search() && get_query_var( 'paged' ) == 0 && ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
<?php echo '<div class="page-description">' . apply_filters( 'the_content', $shop_page->post_content ) . '</div>'; ?>
<?php endif; ?>

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

<?php if ( have_posts() ) : ?>
<span class="codenegar-shop-loop-wrapper">

<?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(); ?>
</span>
<div class="clear"></div>

<?php
//product sorter

/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>

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

<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

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

<?php endif; ?>

<?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
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
//do_action('woocommerce_sidebar');
?>


</div>
<?php if (get_post_meta(get_shop_page_id(),'_wp_page_template',true) == 'template-rightsidebar.php') { ?>
<aside class="grid_3 right-sidebar">
<?php
(get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true)) ? $sidebar = get_post_meta(get_shop_page_id(), SHORTNAME . '_page_sidebar', true) : $sidebar = "default-sidebar";
generated_dynamic_sidebar_th($sidebar); ?>
</aside>
<?php } ?>
<div class="clear"></div>


<?php get_footer('shop'); ?>

Edit* had a reply from the auther which doesn't really help;

Hi,

Yes the problem is what described in the documentation.

The solutions are easy, and we provided three methods to solve this.

Your source code shows that your template use hooks but in wrong places:

woocommerce_before_shop_loop should be before list of products

woocommerce_after_shop_loop should be after list of products

But you don't need to change the code or replace these hooks, other methods are effective also.
 
Last edited:
Associate
Joined
16 Mar 2013
Posts
396
Without doing it myself, couple of suggestions. Moving the closing span to the end of the opening span so there's nothing in between and try taking the whole line of code and putting before the if statement. The query has run somewhere else so our global $post is set to pull products meaning, it doesn't need to be in the loop as the plugin should get the product list. Having it in the if statement is duplicating it I believe. You've got the plugin going if have products then do this and then it's again checking if there is products because it's all in another if statement. So it's basically going, if there's products get list and if there's products, then if there's products get list. So you're duplicating.

Without seeing the inner workings of the plugin I may be off but that's what comes to mind.
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
Thanks, what your saying does make sense, I have tried it but no luck unfortunately it does update the page but all the products are still there not just the filtered ones.

Also to add when it shows the spining logo like it's loading, I only now have one not like the two I did when I was getting duplicates.
 
Associate
Joined
16 Mar 2013
Posts
396
You tried it before this line?

<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

Just a case of moving it around sometimes, finding where it gets the right data. Not very scientific I know. lol. It's really hard without seeing the site and code to advise.
 
Associate
Joined
16 Mar 2013
Posts
396
yeah sure, send the plugin to [email protected] and I'll put it in a theme and see what's going on. If it works out the box, then I may need you to send over a file with the database, themes and plugins you're using.

If you like, you can create a user account on your site and I can get the database that way.

Would chatting on Skype help as well?
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
yeah sure, send the plugin to [email protected] and I'll put it in a theme and see what's going on. If it works out the box, then I may need you to send over a file with the database, themes and plugins you're using.

If you like, you can create a user account on your site and I can get the database that way.

Would chatting on Skype help as well?

Thanks, I am away until tomorrow. I have had an email from the plug-in author but not been home to try it. I will give it ago let you know how I get on tomorrow.
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
Thanks, I have heard again from the author with some code that still doesn't work, but he has asked for logins.

I will see if he managed to get anything done and will let you know.

Thanks again.
 
Associate
OP
Joined
30 Nov 2010
Posts
2,276
Location
UK
Hi, I have sent the author the logins for FTP and wordpress. That was two days ago, I will give it a little longer maybe til tomorrow lunch time. If I don't hear from him I will email you the logins over if your sure you don't mind taking a look.

Thanks

This was the last message I got from him:

This code, prints all products in the template.



<?php if ( have_posts() ) : ?>

<?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(); ?>



If you can't fix it by yourself ask your theme support to do it or send me temporary login info and I'll try.

That code is exactly the same as I am already using, so no help whatsoever.
 
Associate
Joined
16 Mar 2013
Posts
396
He's just told you the stock code, which is what you've already got. He's blaming the code when it's not the code. Typical plugin dev response.

I'm absolutely happy to look at it for you. If we start with you just sending me the plugin, I can see if it works in one of my custom themes, if not, I can fix in a theme that I know inside and out and then put it into your theme.
 
Back
Top Bottom