Primary result ordering sort by price.

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Primary result ordering sort by price.

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10148
    Dimos Tzemanakis
    Dimos Tzemanakis
    Participant

    Hello there,

    Is it possible the primary result ordering sort by price high-> low. Currently the only options are (relevance, title and date). Is there a filter we can add to functions.php?

    Kind Regards,

    Tzemanakis Dimosthenis

    #10151
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    It’s only possible with a custom function. This should do the trick:

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #10152
    Dimos Tzemanakis
    Dimos Tzemanakis
    Participant

    Thanks for quick reply.

    This code actually sort results by price but sort the relevance results. If you click here you can see search result sort by price high->low of “sams”. But if sou search sams on ajax search pro it’s not the same.

    #10153
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    It probably won’t be the same, because the sorting is done after the relevance search as a post-process.

    It is unfortunately not possible to sort the query by a custom field value without changing the source code. If you use the regular engine, then you can try the following:

    1. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-cpt.php file and go to line 328:

    $priority_select AS priority,

    2. ..and change that line to:

    (SELECT IF(meta_value IS NULL, 0, meta_value) FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key='_price' AND $wpdb->postmeta.post_id=$wpdb->posts.ID) AS priority,

    However this will still not guarantee the same results, but it should be different from the current a bit.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.