WC_Order::needs_payment PHP Метод

needs_payment() публичный Метод

Checks if an order needs payment, based on status and order total.
public needs_payment ( ) : boolean
Результат boolean
    public function needs_payment()
    {
        $valid_order_statuses = apply_filters('woocommerce_valid_order_statuses_for_payment', array('pending', 'failed'), $this);
        return apply_filters('woocommerce_order_needs_payment', $this->has_status($valid_order_statuses) && $this->get_total() > 0, $this, $valid_order_statuses);
    }

Usage Example

 public function WX_Loop_Order_Status()
 {
     //ajax loop
     Log::DEBUG(' start loop !');
     $order_id = $_GET['orderId'];
     $order = new WC_Order($order_id);
     $isPaid = !$order->needs_payment();
     Log::DEBUG(" check_wechatpay_response orderid:" . $order_id . "is need pay:" . $isPaid);
     if ($isPaid) {
         $returnUrl = urldecode($this->get_return_url($order));
         echo json_encode(array('status' => 'paid', 'message' => $returnUrl));
     } else {
         echo json_encode(array('status' => 'nPaid', 'message' => 'nPaid'));
     }
     die('');
 }
All Usage Examples Of WC_Order::needs_payment
WC_Order