Solved

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

Posted on 2014-11-13
9
554 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 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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