• Resolved mpserellis

    (@mpserellis)


    Hello,

    Please could you check what appears to me as a bug. To replicate the bug you will need many products to make at least 2 pages. Without filtering change to page 2. Now using the filter choose options will result in only 1 page of products. Because we are on page 2 when we click filter (ajax enabled) we now get a 404 Not Found page.

    I have been looking at the front.js javascript and can see that in most places just before calling woof_submit_link(woof_get_submit_link()) you reset woof_ajax_page_num back to 1. However, the click event of the filter button doesn’t do that:

    Version 1.2.2.1
    lines 412 – 421:

        jQuery('.woof_submit_search_form').click(function () {
    
    	if (woof_ajax_redraw) {
    	    woof_ajax_redraw = 0;
    	    woof_is_ajax = 0;
    	}
    	//***
    	woof_submit_link(woof_get_submit_link());
    	return false;
        });

    I think therefore the filter is applied to page 2 and when there are not enough products returned by the filter to make up 2 pages we get not found error. Please let me know if you need any more information.

    Thank you
    Mark

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hello Mark

    Please set correct per page( same as in theme settings ) – https://c2n.me/43exwkS.png

    Thread Starter mpserellis

    (@mpserellis)

    Hello,

    I did that but it didn’t not solve the problem (it was previously set as -1). I have disabled caching plugins and force refreshed browser (developer tools also open with disable cache selected) so I can be pretty sure it is not a caching issue.

    Please let me know if you have tested the issue as described because if you have and it returns to page 1 when the filter button is clicked then I need to investigate if there are any plugin conflicts that could be causing the problem. However, I do not think there are.

    Thank you
    Mark

    Hello Mark

    My test – https://c2n.me/43gMK3s

    Thread Starter mpserellis

    (@mpserellis)

    Hello,

    Thank you for taking the time to do the screen capture video. After a lot of searching the problem still persists. I found that the problem is also present on your demo site:

    demo.products-filter.com

    Please go to page 3 on your demo site. Then using only the price slider change the maximum to $15 and click filter. I get page not found.

    What I found was that if you use any other filter it works correctly, the bug is only present when filtering on price only.

    Thank you
    Mark

    Hello

    Please drop exact link to the issue!

    Thread Starter mpserellis

    (@mpserellis)

    Link and instructions how to reproduce issue was in my previous comment. After following instructions I provided above you will get:

    https://demo.products-filter.com/page/3/?min_price=7&max_price=15

    Hello

    I requested a link to your site

    Thread Starter mpserellis

    (@mpserellis)

    Hello,

    You don’t need that because the issue is present on your demo site as demonstrated previously. Have you checked? Have I not explained well enough that you can replicate it? I do not wish to put my link here.

    Thank you
    Mark

    Hello Mark

    The reason for this behavior on the demo site is – compressed JS.

    Ok! In this case the solution for you – disable js optimization!

    Thread Starter mpserellis

    (@mpserellis)

    No, this is not a solution! But just to try your suggestion I set up a brand new WordPress site. All I did was install WooCommerce, import the sample products, and install your plugin latest (free) version.

    The only configuration I did was to enable all items under Structure (search by price is set as “woo range-slider”). And under options I changed “set filter automatically” to “yes” and “Autosubmit” to “no”.

    That’s it, there are no javascript optimization plugins and no caching. The problem still persists. Please go to https://woof-test.mpserellis-dev.co.uk/shop/page/2/. This is page 2 of the sample products.

    • Click on the “magnifying glass” icon to expand your filter.
    • Reduce the maximum price to £8
    • DO NOT select any other filter options
    • Click “filter” button

    You will see “Oops! That page can’t be found.” instead of showing the 1 product that falls within that price range.

    There is clearly a bug in your code and not necessarily anything to do with the javascript I initially highlighted. I am going to spend some time in your code trying to figure this out because you seem unwilling to take it seriously and I will post back here in case it helps anyone else.

    Thread Starter mpserellis

    (@mpserellis)

    Hello,

    This is how I have fixed the problem. I changed part of the function woof_get_submit_link() found in front.js by adding one line as shown below. The line I added removes the /page/x from the url before submitting:

        if (Object.keys(woof_current_values).length === 2) {
    	if (('min_price' in woof_current_values) && ('max_price' in woof_current_values)) {
    	    var l = woof_current_page_link + '?min_price=' + woof_current_values.min_price + '&max_price=' + woof_current_values.max_price;
    
    
          l = l.replace(new RegExp(/page\/(\d+)\//), "");
    
    
    	    if (woof_is_ajax) {
    		history.pushState({}, "", l);
    	    }
    	    return l;
    	}
        }
    

    This is something you do further down the same function if there are other options selected but in this case we only have min_price and max_price so before my fix your javascript was not returning to page 1.

    If this helps anyone before the plugin author releases a fix and if you have enabled “Optimize loading of WOOF JavaScript files” found under Settings > Advanced then you will also need to change the front_comprssd.js script or disable the optimization so that it uses front.js.

    Regards
    Mark

    • This reply was modified 5 years, 6 months ago by mpserellis.

    Hello Mark

    Thank you for cooperation! But it is already added in the latest version.

    Thread Starter mpserellis

    (@mpserellis)

    I can assure you it is not in the latest version 1.2.2.1 !! That is the version I was using and is the version used in the demonstration I have set up!

    It seems you are very unwilling to accept there is anything wrong. Tell me, have you seen the issue I have described? Have you been to the test site I set up specifically to prove the point? Have you checked the code I provided to fix the issue?

    Hello

    Yes of course I did it! But the first thing I did was check it out on my on site! And it worked correctly (I gave you a video – https://c2n.me/43qedsf.png ) The latest(paid) version of the plugin is installed on this site. And there is a fix in front.js.

    Have you checked the code I provided to fix the issue? – not! Because it is already fixed.

    Thread Starter mpserellis

    (@mpserellis)

    Hello,

    Right, the video you provided does NOT replicate the issue I described which is why I kept replying to your comments. A number of times now I told you that it ONLY occurs when you ONLY use the price slider! The video you provided shows you selecting one of the check boxes!

    I have just checked your demo site again and it is NOT working there, it still gives “Oops! That page can’t be found.”.

    Please try it again on your site and use ONLY the price slider to filter. Go to page 3 of your demo site and then slide the max price down to 16. Do not select any other filter option. You WILL get page not found just as I do.

    Please, I am asking you to re-read my comments describing how to replicate the issue.

    Thank you
    Mark

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Possible bug causes 404 Not Found page’ is closed to new replies.