Tagged: infinite scroll, Lazy Load, woocommerce
-
AuthorPosts
-
October 27, 2015 at 2:40 pm #525495
Hello,
I am trying to add lazy load functionality to my website made with Enfold, and I think I am close to make it work, however for now I keep getting repeated products as I scroll down.
I believe this is due to the default pagination from woocommerce being replaced by ‘avia_pagination’ ,which only displays numbered page links, and doesn’t have a ‘next page’ link, so I am having to set my ‘Next Selector’ for the lazy load as being
nav.pagination a:first
, which I think is making the lazy load script keep loading the same products over and over.Could you help me replace the ‘avia_pagination’ on shop pages with WooCommerce’s default pagination? Or even just adding a ‘next page’ link/button to avia’s pagination.
Best regards,
JoséOctober 27, 2015 at 4:08 pm #525543Hey José!
In the /enfold/config-woocommerce/config.php file try commenting out lines 691.
add_action( 'woocommerce_after_shop_loop', 'avia_woocommerce_after_shop_loop', 10);
Line 120.
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); //remove woo pagination
And 99 – 100.
remove_action( 'woocommerce_pagination', 'woocommerce_catalog_ordering', 20 ); remove_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 );
That will remove the avia pagination and use the woocommerce default pagination.
Cheers!
Elliott- This reply was modified 9 years ago by Elliott.
October 27, 2015 at 4:38 pm #525582Hi Elliot,
First of all thank you for the quick reply.
I had already come across those lines in the code and thought something like that would work, but I am working with a child-theme so I can freely update my Enfold parent theme, and I tried copying that file over to the child-theme and do those changes there, but apparently I’m not able to override those config files like I normally do with child themes.
Meanwhile I’ve also tried doing those changes straight to Enfold’s parent files, and it does indeed work that way, although it needed some minor changes.
If I just comment out line 691, the ‘content container around the shop loop’ is no longer properly closed and as such, the sidebar gets moved to the bottom of the page, after the pagination, so I just commented out line 697 instead:
if(isset($avia_config['overview'] )) echo avia_pagination('', 'nav');
and I changed line 691 to
add_action( 'woocommerce_after_shop_loop', 'avia_woocommerce_after_shop_loop', 11);
so that the content container is closed after the inclusion of woocommerce’s default pagination.Now if you could help me find a way to do these changes for the child-theme only, this solution would be perfect for what I’m trying to achieve.
Best regards,
JoséOctober 27, 2015 at 5:27 pm #525654I have been fiddling around some more and I think I may have found a reasonable solution.
In my child-theme functions.php I added:
add_action( ‘woocommerce_pagination’, ‘woocommerce_pagination’, 9 );
add_action( ‘woocommerce_after_shop_loop’, ‘woocommerce_pagination’, 9 ); //add woo pagination again
I also tried adding:
remove_action( ‘woocommerce_after_shop_loop’, ‘avia_woocommerce_after_shop_loop’, 10);
add_action( ‘woocommerce_after_shop_loop’, ‘dz_woocommerce_after_shop_loop’, 10);function dz_woocommerce_after_shop_loop()
{
echo “</div></main>”; //end content
}with the intention of removing
avia_pagination
which became redundant, while still properly closing the content container, but somehow theavia_woocommerce_after_shop_loop
function is still being loaded and it was messing up my HTML structure (trying to close the content container twice), so I ended up removing that second block of code for now, and I think I’ll end up just hidingavia_pagination
through CSS.Any suggestions to improve this solution will be much appreciated.
EDIT:
As I have been doing some further testing to this, I came across some weird behaviour: if I’m using woocommerce’s default ordering for my products, the lazy load seems to work properly, however when I’m sorting my products by “Most Recent” (which is what I have to use for the production site), some products are being loaded more than once. I am currently at a complete loss as to how I can troubleshoot this problem so, again, any insight on this will be greatly appreciated.EDIT 2:
So this morning I gave it another go, tried changing my ‘Container Selector’ from.products
tomain.template-shop
and suddenly I no longer have repeating products, so I think that fixed my latest and biggest problem. Now I’d just like to know if there is a way to prevent avia_pagination from being loaded for the shop pages in my child-theme, but I can live with having it hidden through CSS.Best regards,
José- This reply was modified 9 years ago by dZ_EB. Reason: found solution for issue from first edit
October 28, 2015 at 4:48 pm #526276Hi!
Not sure, but you should be able to hide it with this CSS.
.woocommerce .pagination { display: none !important; }
Cheers!
ElliottOctober 29, 2015 at 6:38 pm #527072Yes, I had already implemented that CSS ‘fix’, I was just wondering if there was a ‘cleaner’ way of preventing
avia_pagination
from loading on my shop archives, and without ‘hacking’ the theme’s parent files.But if there isn’t, this solution should be good enough, thanks for the support anyway!
EDIT: Ok now all of a sudden I am getting repeated products again with my lazy load. Now I’m even doubting if I ever had it fixed but just wasn’t spotting the duplicates. Once again I’m completely out of ideas on how to troubleshoot this, so any help in getting to the bottom of this would be hugely appreciated.
Best regards,
José- This reply was modified 9 years ago by dZ_EB.
November 2, 2015 at 8:45 pm #528785Hey!
In the loop-index.php file you can try changing line 258 from this.
if(empty($avia_config['remove_pagination'] ))
To this.
if(empty($avia_config['remove_pagination'] ) && !is_archive())
But I think the CSS is better because it will be saved between updates.
Regards,
Elliott- This reply was modified 9 years ago by Elliott.
November 9, 2015 at 2:35 pm #532594Hi again,
Thanks for your suggestions.
I will go with your advice and stick to “hiding with CSS” as that seems to be the cleanest and most future-proof solution available.However, I am still struggling with the issue of having some products showing up more than once in my ‘shop’ page, although I think I have gathered some more information on the problem.
It seems to be a problem with WooCommerce itself, as I have tried totally deactivating the infinite scroll functionality, and even switching themes between Enfold and Storefront (WooCommerce default theme) and I still get some products showing duplicates (on different pages).
It seems to be related to the ‘sorting options’ in WooCommerce because I don’t see any duplicate products if I choose the ‘Default Sorting’ or if I ‘sort by average rating’, but I always get duplicate products if I ‘sort by popularity’ or ‘sort by newness’ / most recent (which is the sorting I want to use).I still have the development version available in case you want to do some tests on it, the credentials for access are still the ones provided on my OP.
I’m going to try and reach Woothemes support as well, since I believe this problem to be with their plugin, but any help you might be able to provide on this will be very much appreciated.
Best regards,
JoséNovember 10, 2015 at 4:47 pm #533433November 10, 2015 at 7:45 pm #533625Hi Elliot,
I have opened a thread here , but from what I gathered, WooThemes usually only provides support to their paying costumers (which I am not) so I don’t have high hopes of getting an answer there.
The weirdest thing is I have previosuly developed another similar site with Enfold, also using the ‘sorting by newness’ option and I’ve never encountered any repeating products.
I recently even went back to that site and managed to implement the infinite scroll feature I had been discussing in this post and it is working without a problem there ( http://www.creativemary.com.pt ), which leads me to believe something went quite wrong with just this site, but I am not being able to figure out what, or how to fix it.The last thing I want is having to rebuild the entire site just because of this weird bug, but I am reaching a point where I’m not seeing any other solution, so if anyone can help me figure out what’s wrong here I’ll be forever grateful.
Best regards,
José AlmeidaNovember 12, 2015 at 5:58 pm #534938Hi!
you have posted to general WordPress forum instead of WooCommerce support, which you can find here.
Regards,
AndyNovember 12, 2015 at 7:58 pm #535058Hi Andy,
Yes I am aware of that, however they only allow paying costumers to submit tickets, and since I haven’t purchased anything from WooThemes until now, I am unable to do so.
Regards,
José
November 16, 2015 at 6:13 pm #536751Hey!
It would probably be best to hire a freelancer to help integrate that plugin then as it’s outside the scope of our support.
Best regards,
Elliott- This reply was modified 9 years ago by Elliott.
-
AuthorPosts
- You must be logged in to reply to this topic.