Sort listing by price not working

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

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

Open Support Ticket
  • Author
    Posts
  • #381983

    stillwater
    Full Member
    Post count: 44

    Hey all,

    Our sort functionality appears to have stopped working. Originally it was working. We originally had a custom field checkbox that if checked, sort would place those Hotels at the top of the result list.

    I just modified to use the price points feature since it seems to be better than a checkbox.

    We now have two price points – free (ID 2) and Paid Member (ID 3).

    We have followed this tutorial to get our price points registered for all hotels in the system: https://wpgeodirectory.com/how-to-sort-listings-by-price/

    
    
    /* BLLA Paid Member Checker */
    // fire the function every time a listing is published or edited
    add_action('geodir_after_save_listing','my_change_custom_field_on_save',10,2);
    
    // this is the function that will set the correct value in the blla_member custom field
    function my_change_custom_field_on_save($post_id, $post_info){
      //Checks for package ID 2, the free price in our example
      if (isset($post_info['package_id']) && $post_info['package_id']=='2') {
      //set position number 2 in geodir_blla_member for the free price
        geodir_save_post_meta($post_id, 'geodir_blla_member','2');
      //Checks for package ID 3, the paid price in our example
      } elseif (isset($post_info['package_id']) && $post_info['package_id']=='3') {
      //set position number 1 in geodir_blla_member for the paid price
        geodir_save_post_meta($post_id, 'geodir_blla_member','1');
      }
    }
    
    //this is the function to update all existing listings at once. It won't do anything until we call it from within a template.
    function my_change_custom_field_on_save_existing() {
      global $wpdb;
      //set position 2 for unpaid price on custom field geodir_my_custom_sort
      $wpdb->query("UPDATE 'wp_geodir_gd_hotel_detail' SET 'geodir_blla_member'=2 WHERE 'package_id'=2");
      //set position 1 for paid price on custom field geodir_my_custom_sort
      $wpdb->query("UPDATE 'wp_geodir_gd_hotel_detail' SET 'geodir_blla_member'=1 WHERE 'package_id'=3");
    }

    my_change_custom_field_on_save_existing() has been run, and everything existing has been set the Free price point as default.

    Field has been added to Sort Options, default search ascending, is active.

    Still, results do not filter by Paid price (position 1).

    Example: http://stay-boutique.com/?geodir_search=1&stype=gd_hotels&s=+&snear=los+angeles&sgeo_lat=34.0522342&sgeo_lon=-118.2436849

    The Standard Hotel has been flagged as a Paid Member in the admin section, yet does not appear first in the list.

    Have I got an error in my code?

    #381988

    stillwater
    Full Member
    Post count: 44

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382136

    Paolo
    Site Admin
    Post count: 31206

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382143

    stillwater
    Full Member
    Post count: 44

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382144

    Paolo
    Site Admin
    Post count: 31206

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382145

    stillwater
    Full Member
    Post count: 44

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382147

    Paolo
    Site Admin
    Post count: 31206

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

    #382155

    stillwater
    Full Member
    Post count: 44

    A valid license is required to view this reply.

    You may need to login

    OR

    Buy either a Membership or valid license for this product.

    Thanks, Team GeoDirectory!

Viewing 8 posts - 1 through 8 (of 8 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