Order Listings by Pricing Package

This topic contains 8 replies, has 4 voices, and was last updated by  Good Faith Hope 9 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #26695

    commint
    Free User
    Post count: 19

    Hi there,

    I was wondering if it is possible to sort the listings according to the package the business has signed up for. My client’s pricing model will include 2 or 3 levels of featured listings. Ideally the highest paid listings would appear first. Here is an example of what I mean:

    1. Zebra ($500 featured listing)
    2. Elephant($250 featured listing)
    3. Squirrel ($250 featured listing)
    4. Aardvark ($250 featured listing)
    5. Cat (free listing)
    6. Dog (free listing)
    7. etc etc etc

    I am using the Prices and Payments add-on with GDF Modern Child Theme. WP and all plugins are up to date (fresh install). Many thanks.

    #26721

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    The package id is available in the post object and in the joint tables so it would be possible but you would have to modify the query.

    Where are u trying to display this, on the listing pages or just in the widgets?

    Stiofan

    #26763

    commint
    Free User
    Post count: 19

    Hi Stiofan, thanks for the reply.

    Specifically I want to do this on the listing pages. Doing it in widgets is unlikely but may come up in the future as the project is continually evolving.

    Cheers,
    Kieran

    #26766

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Kieran,

    This would be considered customisation but here i some code to get u started, you would add this to your child theme functions.php

    
    
    add_filter('geodir_posts_order_by_sort', 'geodir_posts_order_by_sort_my_change',10,3);
    
    function geodir_posts_order_by_sort_my_change($orderby, $sort_by, $table){
    
    if($orderby==' '){
    //$orderby = " $table.package_id asc, ";// simply order by package id lowest to greatest
    $orderby = " FIELD($table.package_id,1,5,4,3), "; // order by specific package id's
    }
    
    return $orderby;
    }

    Thanks,

    Stiofan

    #26781

    commint
    Free User
    Post count: 19

    Thanks for pointing me in the right direction Stiofan. This works perfectly. Just wondering, is there a repository available of the most useful/popular hooks?

    #26784

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Not at the moment, one of my tasks for the month is to create it 🙂

    Thanks,

    Stiofan

    #53223

    Good Faith Hope
    Buyer
    Post count: 66

    Hi Commint,

    Can you share how you managed to get this working? I reordered my package IDs and changed the code to:

    
    
    $orderby = " $table.package_id asc, ";// simply order by package id lowest to greatest
    //$orderby = " FIELD($table.package_id,1,5,4,3), "; // order by specific package id's
    }

    Unfortunately I had a previous directory theme that allowed members to purchase packages to appear higher in search results. I’m desperate to get this working with Geodirectory. Any help is appreciated!

    #53235

    Guust
    Moderator
    Post count: 29970

    @dee C
    With the prices and payment addon, you can create packages that are featured, and then you can sort the listing displays by Featured first.
    That is not the same of course as ordering by all of your price packages.

    #53259

    Good Faith Hope
    Buyer
    Post count: 66

    Got the code working 😀 😀 😀

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount