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:
James Allan 2017-11-30 13:31:10 +10:00
parent 9e15022370
commit f6eb02806b
3 changed files with 18 additions and 6 deletions

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );