Example #1
0
 /**
  * Retrieves an existing order by ID.
  *
  * @param int $order_id Order ID
  *
  * @return object|bool APP_Order Object representing the order. Boolean False on failure.
  */
 public static function retrieve($order_id)
 {
     if (!is_numeric($order_id)) {
         trigger_error('Invalid order id given. Must be an integer', E_USER_WARNING);
         return false;
     }
     $order_data = get_post($order_id);
     if (!$order_data || $order_data->post_type != APPTHEMES_ORDER_PTYPE) {
         return false;
     }
     // retrieve an escrow order instead if the order is flagged as escrow
     if (appthemes_is_escrow_order($order_id)) {
         return APP_Escrow_Order_Factory::retrieve($order_id);
     }
     if (appthemes_is_recurring_available()) {
         return new APP_Recurring_Order($order_data, self::get_order_items($order_id));
     }
     $order = new APP_Instant_Order($order_data, self::get_order_items($order_id));
     return $order;
 }
Example #2
0
 public function display($post)
 {
     $this->admin_script($post);
     $is_escrow = appthemes_is_escrow_order($post->ID);
     if (!in_array($post->post_status, array(APPTHEMES_ORDER_COMPLETED, APPTHEMES_ORDER_FAILED, APPTHEMES_ORDER_REFUNDED, APPTHEMES_ORDER_ACTIVATED))) {
         if ($is_escrow) {
             if (APPTHEMES_ORDER_PAID == $post->post_status) {
                 $this->display_button('complete-order', __('Mark as Completed', APP_TD));
             }
             if (APPTHEMES_ORDER_PENDING == $post->post_status) {
                 $this->display_button('fail-order', __('Mark as Failed', APP_TD));
             } else {
                 $this->display_button('fail-order-refund', __('Mark as Failed (Refund)', APP_TD));
             }
         } else {
             $this->display_button('complete-order', __('Mark as Completed', APP_TD));
             $this->display_button('fail-order', __('Mark as Failed', APP_TD));
             $this->display_button('reset-gateway', __('Reset Gateway', APP_TD));
         }
     } else {
         if ($post->post_status == APPTHEMES_ORDER_FAILED && !$is_escrow) {
             $this->display_button('reset-order', __('Reset Order', APP_TD));
         } else {
             if ($post->post_status == APPTHEMES_ORDER_COMPLETED && !$is_escrow) {
                 $this->display_button('activate-order', __('Activate Order', APP_TD));
             } else {
                 printf('<em>%s</em>', __('No actions available', APP_TD));
             }
         }
     }
 }