?
Solved

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

Posted on 2014-11-13
9
Medium Priority
?
627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 SignAloud Glove is capable of translating American Sign Language signs into text and audio.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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