• Resolved qtwrk

    (@qtwrk)


    Hi,

    I recently noticed the price sort , both from high to low and reverse, doesn’t work on search result page

    first I thought might be plugin or theme issue , but when I disable all plugins only keep Woo 8.4.0 , and StoreFront 4.5.3 , but issue persist

    please give me some help how to resolve this problem.

    best regards,

Viewing 15 replies - 1 through 15 (of 15 total)
  • Saif

    (@babylon1999)

    Hello @qtwrk,

    Thank you for reaching out!

    I recently noticed the price sort , both from high to low and reverse, doesn’t work on search result page

    I’m not able to reproduce this with the Price filter widget block, as you can see in the screenshot below.


    Link to image: https://d.pr/i/0lIALW

    Could you share your site’s System Status report? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support” (after you scroll down a bit)”. Please paste it here or use a text-sharing service like https://gist.github.com/.

    Adding a few screenshots of what you’re seeing would also be helpful.

    If you don’t already have a screenshot service installed, here are a few free options: 

    Look forward to hearing back from you.

    Thread Starter qtwrk

    (@qtwrk)

    Hi, @babylon1999

    thanks for reply , please check https://pastebin.ubuntu.com/p/Nh2X9SnXtV/

    there is the domain , you can go to the site , for example search “maquina” , in result page, you can check and try the sorts, none of these sorts works

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hey @qtwrk,

    I appreciate you providing additional information. I’ve checked your site, and everything seems to be in order. The price sorting function is working perfectly on my end.

    From my experience, this could be resolved by clearing your browser’s cache and cookies. You can follow our detailed guide on clearing browser cache here: https://wordpress.com/support/browser-issues/#clearing-your-browser-cache

    Additionally, head over to WooCommerce → Status → Tools, and do the following:

    • WooCommerce transients – Clear
    • Expired transients – Clear
    • Clear template cache – Clear
    • Capabilities – Reset Capabilities
    • Clear customer sessions -Clear
    • Product lookup tables – Regenerate
    • Regenerate the product attributes lookup table – Regenerate

    If this doesn’t work or you have more questions, just let us know, and we’ll be happy to help!

    Thread Starter qtwrk

    (@qtwrk)

    Hi,

    you need to check on search result page , search , for example maquina , and in result page, sorting is not working

    I did all the clear/regenerate/reset in Tools , still same.

    and yes , I tried on private window , multiple newly installed/clean browsers , all same issue.

    • This reply was modified 11 months ago by qtwrk.
    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hey @qtwrk,

    Thanks for sharing the additional details. I’ve tried to replicate the issue on your website following your steps and was successful. However, when I attempted the same on my testing site, I encountered no problems. This was the case for an older site and a freshly set-up one – everything worked fine.

    Would you mind trying to reinstall the WooCommerce plugin? Additionally, could you disable the server cache temporarily for testing purposes? Also, delete all the files stored in the cache folder inside the wp-content folder.

    I ask this because, while I change the sorting option, the page reloads, and the URL parameter changes accordingly (?orderby=price&paged=1&s=maquina&search_id=1&post_type=product). Only the style and content on the page don’t update. I also noticed the same warning appearing in the console too.

    Let us know how that goes. Looking forward to helping you.

    Thread Starter qtwrk

    (@qtwrk)

    hi @shameemreza ,

    thanks for reply , no , I don’t have any cache activated, except opcache but I don’t think it is caching anything

    I also explicitly set to my server to send out header

    cache-control: no-cache, no-store, must-revalidate, max-age=0

    to disable browser cache.

    tried reinstall Woo , didn’t work

    I also added

    <?php echo "random number:" . rand(1,999999); ?>

    to head , this will tell the page was regenerated by PHP

    • This reply was modified 11 months ago by qtwrk.
    Saif

    (@babylon1999)

    Hey @qtwrk,

    This is very unusual! Can you please try regenerating the product lookup table data from WooCommerce > Status > Tools > Product lookup tables?

    Let us know how it goes!

    Thread Starter qtwrk

    (@qtwrk)

    hi @babylon1999

    Your colleague has already suggested that in 2nd reply, and I tried it, didn’t work

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi again @qtwrk,

    I understand you are still facing the same issue even after following the troubleshooting steps suggested by my colleagues.

    I’d like to understand your site properly. Please share with us the necessary information below for us to investigate the issue further:

    System Status Report which you can find via WooCommerce > Status > Get system report > Copy for support.
    Fatal error logs (if any) under WooCommerce > Status > Logs.
    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Once we have more information, we’ll be able to assist you further.

    Thread Starter qtwrk

    (@qtwrk)

    Hi, @ckadenge

    I have shared the system report on my 3rd reply if you haven’t noticed that , but I will paste the link again : https://pastebin.ubuntu.com/p/Nh2X9SnXtV/

    and No , no any fatal error log , last log shows is from 27th the day I switch to storefront theme and it triggers the thumbnails regeneration

    and if any case, I will list summarize the things you may or may not ask me to check to save us time.

    1. no cache system in place , with explicitly set cache-control: no-cache, no-store, must-revalidate, max-age=0 header to disable browser cache
    2. tried on multiple different browser and at certainty no browser cache was affecting this
    3. tried all the clear/regenerate things in Woo -> status -> tools
    4. all other plugins are disabled, only Woo and StoreFront theme are active
    5. added rand(1,99999) php code in header to verify the page is regenerated by PHP , which it is as each time sorting or refreshing the page, the generated random number changes

    Best regards,

    • This reply was modified 11 months ago by qtwrk.
    • This reply was modified 11 months ago by qtwrk.
    Afzal (woo-hc)

    (@afzalpansuvi)

    Hi there,

    I understand that you are having trouble sorting the products by price on the search result page.

    There are a few possible solutions to this problem. Here are some steps you can try:

    • Change the default product sorting to “Sort by price (asc)”. You can do this in your WordPress dashboard by going to Appearance → Customize → WooCommerce → Product Catalog and selecting “Sort by price (asc)” from the “Default product sorting” dropdown.
    • Use a custom code snippet to modify the product query. You can add the following code to your functions.php file or use a plugin like Code Snippets to insert it:
    add_action ( 'woocommerce_product_query', 'jwc_custom_product_query' );
    function jwc_custom_product_query ( $query ) {
      if ( ! $query->is_main_query () ) return;
      if ( ! isset ( $query->query ['s'] ) ) return;
      $query->set ( 'order', 'ASC' );
      $query->set ( 'orderby', 'price' );
      return $query;
    }

    This code will sort the products by price in ascending order on the search page.

    I hope this helps you resolve your issue. If you have any further questions or need more assistance, please let us know.

    Thread Starter qtwrk

    (@qtwrk)

    Hi, @afzalpansuvi

    thanks for reply , the first method didn’t work , no effect at all

    the code snippet did change the default order of search result , but unfortunately the sorting price low->high or high-> low is still not working

    the code on stackoverflow did give me an hint

    add_filter('woocommerce_get_catalog_ordering_args', function ($args) {
        $orderby_value = isset($_GET['orderby']) ? wc_clean($_GET['orderby']) : apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
    error_log( print_r($args, true), 3, '/xxx/output.log' );

    I dumped out the $args but it seems stuck onto

    [root@server1 /var/www/html/]# cat output.log
    Array
    (
        [orderby] => relevance
        [order] => DESC
        [meta_key] =>
    )

    relevance + DESC no matter what sorting I choose,

    which makes feel maybe the query string didn’t pass in ?

    so I did another dump to$_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING']

    query string:s=maquina&search_id=1&post_type=product
    request uri:/?s=maquina&post_type=product
    query string:s=maquina&search_id=1&search_id=1&post_type=product
    request uri:/?orderby=price-desc&paged=1&s=maquina&search_id=1&post_type=product

    the first set is the default one , which is “relevance” but when I change to price sorting , the request URI grabbed the ?orderby=price-desc , but now it makes me crazy as how come the query string doesn’t have it ?

    best regards,

    • This reply was modified 11 months ago by qtwrk.
    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @qtwrk,

    To be honest, your issue is unusual, and the orderby parameter isn’t present in the query string, despite being in the request URI, which is indeed puzzling.

    Could you please check your .htaccess file to see if any rules might affect the query string? Also, you may try using a plugin like Query Monitor to see if it provides any additional information about the query string.

    By the way, on my latest test, it looks like the sorting is working your your search result page (orderby=price&paged=1&s=maquina&search_id=1&post_type=product).

    I also recommend asking this questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer more insights into your issue.

    Please let us know the results of these steps. Looking forward to hearing from you.

    Thread Starter qtwrk

    (@qtwrk)

    oh man , yes , that’s it , I had a rewrite rule in my .htaccess that I had to enable it long time ago in order to make one of my needed plugin working , that rule altered the query string specifically on the search query

    thanks a lot without mention it I couldn’t think of it even next year : )

    despite I have worked out the code snippet to grab from REQUEST_URI , but this dig out the root cause it

    many thanks , and happy new year.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @qtwrk,

    I am happy to hear this has helped. ??

    If it isn’t too much to ask for – would you mind leaving us a review here?

    It only takes a couple of minutes but helps us tremendously. It would mean so much to us and would go a really long way.

    Should you have further inquiries with WooCommerce core, feel free to create a new topic.

    Happy New Year! ????

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘WooCommerce search result page can not be sorted by price’ is closed to new replies.