该函数位于类WC_Abstract_Order(核心文件)中
/* Checks if an order needs payment, based on status and order total.
*
* @return bool
*/
public function needs_payment() {
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $this );
if ( $this->has_status( $valid_order_statuses ) && $this->get_total() > 0 ) {
$needs_payment = true;
} else {
$needs_payment = false;
}
return apply_filters( 'woocommerce_order_needs_payment', $needs_payment, $this, $valid_order_statuses );
}
Run Code Online (Sandbox Code Playgroud)
我需要向数组添加其他自定义订单状态,但无法计算出functions.php的代码以覆盖该函数,就像这样-即仅具有添加的状态:
public function needs_payment() {
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed','neworderstatus' ), $this );
if ( $this->has_status( …Run Code Online (Sandbox Code Playgroud)