get_status(); $total = (float) $order->get_total(); if ( in_array( $status, [ 'pending', 'on-hold', 'failed' ], true ) && $total > 0 ) { return true; } } return $needs_payment; } public function grant_admin_pay_cap( $allcaps, $caps, $args ) { if ( isset( $args[0] ) && 'pay_for_order' === $args[0] && current_user_can( 'manage_woocommerce' ) ) { $allcaps['pay_for_order'] = true; } return $allcaps; } public function bypass_ownership_on_order_pay() { if ( is_wc_endpoint_url( 'order-pay' ) && is_user_logged_in() && current_user_can( 'manage_woocommerce' ) ) { remove_action( 'woocommerce_order_pay', 'wc_order_is_valid_for_payment_check', 10 ); } } public function maybe_allow_admin_payment_statuses( $statuses, $order ) { $allow_payment = get_option( 'aisp_otools_allow_on_hold_payment', 'no' ); if ( 'yes' !== $allow_payment ) { return $statuses; } $statuses[] = 'on-hold'; $statuses[] = 'pending'; $statuses[] = 'failed'; return array_unique( $statuses ); } }