예제 #1
0
 public function get_latest_payments()
 {
     return WPBDP_Payment::find(array('listing_id' => $this->id, '_order' => '-id', '_limit' => 10));
 }
예제 #2
0
 /**
  * @since 3.5.8
  */
 public function abandonment_status($status, $listing_id)
 {
     // For now, we only consider abandonment if it involves listings with pending INITIAL payments.
     if ('pending' != $status || !$listing_id || !wpbdp_get_option('payment-abandonment')) {
         return $status;
     }
     $last_pending = WPBDP_Payment::find(array('listing_id' => $listing_id, 'status' => 'pending', '_single' => true, '_order' => '-created_on'), true);
     if (!$last_pending || 'initial' != $last_pending['tag']) {
         return $status;
     }
     $threshold = max(1, absint(wpbdp_get_option('payment-abandonment-threshold')));
     $hours_elapsed = (current_time('timestamp') - strtotime($last_pending['created_on'])) / (60 * 60);
     if ($hours_elapsed <= 0) {
         return $status;
     }
     if ($hours_elapsed >= 2 * $threshold) {
         return 'payment-abandoned';
     } elseif ($hours_elapsed >= $threshold) {
         return 'pending-abandonment';
     }
     return $status;
 }