Plugin Directory

Changeset 1244784


Ignore:
Timestamp:
09/14/2015 04:10:02 AM (10 years ago)
Author:
trackhs
Message:

1.7 fixes

Location:
track-connect/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • track-connect/trunk/includes/api/request.php

    r1243633 r1244784  
    230230
    231231        $unitArray = [];
    232         foreach(json_decode($units['body'])->response as $unit){
    233             $query = $wpdb->get_row("SELECT post_id FROM wp_postmeta WHERE meta_key = '_listing_unit_id' AND meta_value = '".$unit."' LIMIT 1; ");
     232
     233        if(json_decode($units['body'])->success == false){
     234            return [
     235                'success' => false,
     236                'message' => json_decode($units['body'])->message
     237            ];
     238        }
     239        foreach(json_decode($units['body'])->response->available as $cid=>$avgRate){
     240            $query = $wpdb->get_row("SELECT post_id FROM wp_postmeta WHERE meta_key = '_listing_unit_id' AND meta_value = '".$cid."' LIMIT 1; ");
    234241            $unitArray[] = $query->post_id;
    235 
    236         }
    237 
    238         return $unitArray;
     242            $rateArray[$cid] = $avgRate;
     243
     244        }       
     245       
     246        return [
     247            'success' => true,
     248            'units'   => $unitArray,
     249            'rates'   => $rateArray
     250        ];
    239251    }
    240252   
  • track-connect/trunk/includes/views/archive-listing.php

    r1240960 r1244784  
    113113        $count = 0; // start counter at 0
    114114        $unitsAvailable = true;
    115 
    116         if($checkAvailability && !count($availableUnits)){
    117             echo '<div align="center" style="padding:25px;">No units are available from '. date('m/d/Y', strtotime($checkin)) . ' to ' .  date('m/d/Y', strtotime($checkout)). '.</div>';
     115       
     116        if($checkAvailability && $availableUnits['success'] == false){
     117            echo '<div align="center" style="padding:25px;">'.$availableUnits['message'].'</div>';
    118118            $unitsAvailable = false;
    119119        }
    120 
     120       
     121        $avgRates = null;
     122        $avgRates = $availableUnits['rates'];
     123       
    121124        // Start the Loop. 
    122125        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
     
    142145        }
    143146        if($checkAvailability){         
    144             $args += array('post__in' => $availableUnits);
     147            $args += array('post__in' => $availableUnits['units']);
    145148        } 
    146149        if(get_query_var('status') != ''){         
     
    216219            $loop .= sprintf( '<div class="listing-thumb-meta">' );
    217220           
    218             if ( '' != get_post_meta( $post->ID, '_listing_min_rate', true ) ) {
    219                 $loop .= sprintf( '<span class="listing-property-type">%s</span>', 'starting at' );
     221            if ( $avgRates[$unitId] > 0 ) {
     222                $loop .= sprintf( '<span class="listing-property-type">%s</span>', 'avg. rate' );
     223                $loop .= sprintf( '<span class="listing-price">$%s/night</span>', number_format($avgRates[$unitId],0) );
     224            }else{
     225                $loop .= sprintf( '<span class="listing-property-type">%s</span>', 'starting at' );
    220226                $loop .= sprintf( '<span class="listing-price">$%s/night</span>', number_format(get_post_meta( $post->ID, '_listing_min_rate', true ),0) );
    221227            }
  • track-connect/trunk/plugin.php

    r1243633 r1244784  
    77    Author URI: http://www.trackhs.com
    88
    9     Version: 1.6.9
     9    Version: 1.7
    1010
    1111    License: GNU General Public License v2.0 (or later)
     
    5555
    5656    define( 'WP_LISTINGS_URL', plugin_dir_url( __FILE__ ) );
    57     define( 'WP_LISTINGS_VERSION', '1.6.9' );
     57    define( 'WP_LISTINGS_VERSION', '1.7' );
    5858
    5959    /** Load textdomain for translation */
  • track-connect/trunk/readme.txt

    r1243633 r1244784  
    44Requires at least: 3.7
    55Tested up to: 4.2.3
    6 Stable tag: 1.6.9
     6Stable tag: 1.7
    77
    88Creates and syncs listing-type posts from TRACK PM, a cloud-based property management system (www.trackhs.com).
Note: See TracChangeset for help on using the changeset viewer.