Solved

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

Posted on 2014-11-13
9
389 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mysql update statement effect only some rows 4 27
Problem sending file attachments 8 24
Cannot access my wp-admin account 2 14
Scope of $_SESSION 17 30
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now