Mark orders as payment complete if the order total is 0
Similar to how other payment gateways like Stripe call payment_complete on orders with $0 totals.
This commit is contained in:
parent
9e15022370
commit
f6eb02806b
|
@ -342,8 +342,12 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
|
|||
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
// Mark as on-hold (we're awaiting the payment)
|
||||
$order->update_status( 'on-hold', __( 'Awaiting BACS payment', 'woocommerce' ) );
|
||||
if ( $order->get_total() > 0 ) {
|
||||
// Mark as on-hold (we're awaiting the payment)
|
||||
$order->update_status( 'on-hold', __( 'Awaiting BACS payment', 'woocommerce' ) );
|
||||
} else {
|
||||
$order->payment_complete();
|
||||
}
|
||||
|
||||
// Reduce stock levels
|
||||
wc_reduce_stock_levels( $order_id );
|
||||
|
|
|
@ -113,8 +113,12 @@ class WC_Gateway_Cheque extends WC_Payment_Gateway {
|
|||
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
// Mark as on-hold (we're awaiting the cheque)
|
||||
$order->update_status( 'on-hold', _x( 'Awaiting check payment', 'Check payment method', 'woocommerce' ) );
|
||||
if ( $order->get_total() > 0 ) {
|
||||
// Mark as on-hold (we're awaiting the cheque)
|
||||
$order->update_status( 'on-hold', _x( 'Awaiting check payment', 'Check payment method', 'woocommerce' ) );
|
||||
} else {
|
||||
$order->payment_complete();
|
||||
}
|
||||
|
||||
// Reduce stock levels
|
||||
wc_reduce_stock_levels( $order_id );
|
||||
|
|
|
@ -178,8 +178,12 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
|
|||
public function process_payment( $order_id ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
// Mark as processing or on-hold (payment won't be taken until delivery)
|
||||
$order->update_status( apply_filters( 'woocommerce_cod_process_payment_order_status', $order->has_downloadable_item() ? 'on-hold' : 'processing', $order ), __( 'Payment to be made upon delivery.', 'woocommerce' ) );
|
||||
if ( $order->get_total() > 0 ) {
|
||||
// Mark as processing or on-hold (payment won't be taken until delivery)
|
||||
$order->update_status( apply_filters( 'woocommerce_cod_process_payment_order_status', $order->has_downloadable_item() ? 'on-hold' : 'processing', $order ), __( 'Payment to be made upon delivery.', 'woocommerce' ) );
|
||||
} else {
|
||||
$order->payment_complete();
|
||||
}
|
||||
|
||||
// Reduce stock levels
|
||||
wc_reduce_stock_levels( $order_id );
|
||||
|
|
Loading…
Reference in New Issue