needs_payment for 2.1 #3928
This commit is contained in:
parent
f949b99440
commit
4cabf24422
|
@ -244,7 +244,7 @@ class WC_Form_Handler {
|
|||
WC()->customer->set_city( $order->billing_city );
|
||||
|
||||
// Update payment method
|
||||
if ( $order->order_total > 0 ) {
|
||||
if ( $order->needs_payment() ) {
|
||||
$payment_method = woocommerce_clean( $_POST['payment_method'] );
|
||||
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
|
|
@ -1533,4 +1533,20 @@ class WC_Order {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an order needs payment, based on status and order total
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function needs_payment() {
|
||||
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $this );
|
||||
|
||||
if ( in_array( $this->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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ global $woocommerce;
|
|||
</table>
|
||||
|
||||
<div id="payment">
|
||||
<?php if ($order->order_total > 0) : ?>
|
||||
<?php if ( $order->needs_payment() ) : ?>
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
if ( $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways() ) {
|
||||
|
|
Loading…
Reference in New Issue