-
Notifications
You must be signed in to change notification settings - Fork 24
_list_not_available meta field values not unified in db #97
Copy link
Copy link
Open
Labels
Description
I was searching for the attribute which define if a listing is available or already sold or rented. On my search I've discovered, that the _list_not_available metadata field of a listing is not unified in the database. There are three different values which I saw: 0, 1, on.
In the php function is_listing_not_available which handles this field is a migration integrated from the old field _price_sold_rented. Maybe this is the reason why we have three different values?
I would suggest to add here maybe another migration to bring this values to a consistent type (0, 1).
wpcasa/wpcasa/includes/class-wpsight-listings.php
Lines 1323 to 1363 in c983038
| /** | |
| * is_listing_not_available() | |
| * | |
| * Check if a specific listing item is no longer available | |
| * (custom field '_listing_not_available'). | |
| * | |
| * @param integer $post_id Post ID of the corresponding listing (defaults to current post) | |
| * @uses result() | |
| * @uses get_post_meta() | |
| * @uses update_post_meta() | |
| * @uses delete_post_meta() | |
| * @return bool $result True if _listing_not_available has value, else false | |
| * | |
| * @since 1.0.0 | |
| */ | |
| public static function is_listing_not_available( $post_id = '' ) { | |
| // Set default post ID | |
| if ( ! $post_id ) | |
| $post_id = get_the_ID(); | |
| // Get old _price_sold_rented value | |
| $sold_rented = get_post_meta( $post_id, '_price_sold_rented', true ); | |
| if ( ! empty( $sold_rented ) ) { | |
| // Update new field with old field value | |
| update_post_meta( $post_id, '_listing_not_available', $sold_rented ); | |
| // Remove old field | |
| delete_post_meta( $post_id, '_price_sold_rented' ); | |
| } | |
| // Get custom post meta and set result | |
| $result = get_post_meta( $post_id, '_listing_not_available', true ) ? true : false; | |
| return apply_filters( 'wpsight_is_listing_not_available', $result, $post_id ); | |
| } |
Reactions are currently unavailable