• Resolved itsupportacemsthailand

    (@itsupportacemsthailand)


    hello

    I’m having trouble sorting products by price from the search bar.
    problem is Product prices are not arranged in order. As selected in select as shown in the attached picture.

    https://jmp.sh/0tmiLM7x

    Is it possible if you help me find the cause of it?
    Or if I use the pro version option inside will that fix this problem?

    thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Kris

    (@c0nst)

    Hi @itsupportacemsthailand!

    You can try this solutution:

    // Fix sorting products by price-desc in WooCommerce Search Results Page
    add_action( 'woocommerce_product_query', function( $query ) {
    if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'product' ) ) {
    $orderby = get_query_var( 'orderby' );

    if ( 'price-desc' === $orderby ) {
    $query->set( 'orderby', 'meta_value_num' );
    $query->set( 'meta_key', '_price' );
    $query->set( 'order', 'DESC' );
    }
    }
    } );

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2. or install the Code Snippets plugin and apply this code as a snippet.

    Best regards,
    Kris

    Thread Starter itsupportacemsthailand

    (@itsupportacemsthailand)

    It seems the code still doesn’t work. There is still an error display.

    https://jmp.sh/JVHdO7HN

    Plugin Support Kris

    (@c0nst)

    Hi @itsupportacemsthailand!

    It looks like the code is not working because the orderby parameter is likely being controlled by your theme, page builder, or a filtering plugin. To identify the cause, I suggest the following steps:

    1. Deactivate each plugin one by one (especially any related to filters) to see if the sorting starts working correctly. Then check if the filters you are using are compatible with FiboSearch. We are compatible with:
    1. ?Change your theme to a default WooCommerce-compatible theme like Storefront and check if the issue persists.
    2. ?Check the theme documentation to see if it has built-in sorting or filtering functions that might affect the results.

    Once you’ve tried these, you’ll have a better idea of what’s causing the issue and how to address it.

    Best regards,
    Kris

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.