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-
AuthorPosts
-
June 6, 2017 at 6:41 pm #381983
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).
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?
June 6, 2017 at 6:49 pm #381988A 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!
June 7, 2017 at 4:49 pm #382136A 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!
June 7, 2017 at 5:15 pm #382143A 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!
June 7, 2017 at 5:17 pm #382144A 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!
June 7, 2017 at 5:19 pm #382145A 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!
June 7, 2017 at 5:29 pm #382147A 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!
June 7, 2017 at 5:55 pm #382155A 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!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket