Solved

Woocommerce view all products button link working on shop catalogue but not on search

Posted on 2014-11-13
9
421 Views
Last Modified: 2014-12-06
Hi experts, I am having a problem with woocommerce, on online store...added code to add a view all link inside woocommerce, template pagination.php and functions.php...the button works for the shop catalogue but not for search page, when i run a search for e.g. business, products are displayed but paginated, though the 'view all button' not working here..need help with getting the view all/view less button to work on the search page, help will be much appreciated.  You can test on bookworldzambia.com
0
Comment
Question by:kasondeneddy
  • 6
  • 3
9 Comments
 

Author Comment

by:kasondeneddy
ID: 40441376
I have the following in my functions.php

//NUMBER OF PRODUCTS TO DISPLAY ON SHOP PAGE
add_filter('loop_shop_per_page', 'wg_view_all_products');

function wg_view_all_products(){
      if($_GET['view'] === 'all'){
            return '9999';
      }
}

I need to add a function, filter that will do the same on the search page, search.php, i need to add filter to the search page so the view all button works on the search page..hope I am clear and the above works
0
 

Author Comment

by:kasondeneddy
ID: 40441870
Correction...the view all button just redirects me to the homepage..and does not work in the search page
0
 

Author Comment

by:kasondeneddy
ID: 40441882
Correction...the view all button just redirects me to the homepage..and does not work in the search page
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 15

Expert Comment

by:eemit
ID: 40444076
What happens if you change your "view all" link on Search Result page
from:
http://www.bookworldzambia.com/?view=all
to e.g.:
http://www.bookworldzambia.com/?s=business&post_type=product&view=all
0
 

Author Comment

by:kasondeneddy
ID: 40447000
Hi eemit,

How can I do so?  Where would I change it, I think you are right...not sure where to amend that, in search page code in wordpress, or functions.php?  Thanks for your response
0
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 40449832
You should use is_search() in pagination.php file:
This Conditional Tag checks if search result page archive is being displayed.

And you need something like this in your "View All" link in pagination.php file:
href="<?php echo esc_url( add_query_arg( array( 's' => urlencode(get_query_var('s') ), 'post_type' => get_post_type(), 'view' => 'all' ), home_url("/") ) ); ?>"

Open in new window


Post here your <your current theme>/woocommerce/loop/pagination.php file
0
 
LVL 15

Expert Comment

by:eemit
ID: 40457104
Hi kasondeneddy,
as I can see you have implemented this.
Let us know if you have any other questions about this issue.
0
 

Author Closing Comment

by:kasondeneddy
ID: 40485218
This was very helpful, and indeed the answer to the problem!
0
 

Author Comment

by:kasondeneddy
ID: 40485220
Hi eemit,

I've been unwell and away from the work, thanks for your help, your answer helped get it right!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question