Forum: Premium Settings

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the Premium Settings premium extension please open a new premium support ticket.

[Not resolved]Orderby Price / Rating on Products post types in results

Home Forums Premium Settings Orderby Price / Rating on Products post types in results

This topic contains 5 replies, has 4 voices, and was last updated by  nickisyourfan 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #47897

    Sharon Coleman
    Participant

    Have been stuck on this for some time.

    I would like to have visitors able to order their search results by price and by rating.

    The results are woocommerce products.

    I can add the filter to the search form to narrow down the price BETWEEN, and I have orderby post_date / post_title working fine, but orderby price is beyond me it seems.

    Have tried a few thing by adapting the example coding given here – http://docs.geomywp.com/posts-locator-order-by-filter/

    like

    elseif ( $orderby_value == ‘price’ ) {
    $meta[‘key’] = ‘_regular_price’;
    $clauses[‘orderby’] = ‘meta_value_num’ => ‘ASC’; }

    $clauses[‘orderby’]= $wpdb->prefix.’postmeta.meta_key => _regular_price’, ‘meta_value-num’;

    but just end up with a blank screen.

    I assume that being able to have BETWEEN working means that it must be possible, I just am not good enough with WP/PHP to figure out how it works.

    Any help would be appreciated.

    Sharon

    #48089

    Sharon Coleman
    Participant

    Thinking about this – if an orderby price isn’t possible – then if the BETWEEN numerical custom fields section could be displayed as a slider then that would be a good compromise.

    #49363

    bigint
    Participant

    Hi Sharon,

    I need to do exactly the same, ‘Order WooCommerce products in the search results list by price low to high’. Did you manage to make this work please? If so, are you happy to share your code with me please?

    Thanks,

    Daniel.

    #50230

    Chris Homan
    Participant

    I was trying to do the same and I think I got it to work 🙂

    This is the code I used (snapped from the posts locator dropdown example:

    I attached a file which contains the complete code – the content has to be added to your functions.php file

    Attachments:
    You must be logged in to view attached files.
    #50251

    bigint
    Participant

    Hi Chris,

    Thank you, so much. I put this on the back burner, until my PHP skills improved. I manage to create the odd WordPress filter and hook but I am not expert at PHP. I haven’t tried your code yet, but I am going to, hopefully tomorrow.

    I’ll feed back.

    Thanks again.

    #59448

    nickisyourfan
    Participant

    I know its 3 year later.. But mine only sorts by distance. Nothing else.

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

You must be logged in to reply to this topic.