Merge pull request #17965 from james-allan/complete_payment_using_manual_gateways

Mark $0 orders as payment complete when processing payments with core gateways
This commit is contained in:
Claudiu Lodromanean 2017-12-01 10:21:01 -08:00 committed by GitHub
commit 4443d473ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 );