corsonr
12/3/2013 - 9:02 AM

custom woocommerce BACS class

custom woocommerce BACS class

class WC_Gateway_BACS_custom extends WC_Gateway_BACS {

    /**
     * Process the payment and return the result
     *
     * @access public
     * @param int $order_id
     * @return array
     */
    function process_payment( $order_id ) {
    	global $woocommerce;

		$order = new WC_Order( $order_id );

		// Mark as processing (that's what we want to change!)
		$order->update_status('processing', __( 'Awaiting BACS payment', 'woocommerce' ));

		// Reduce stock levels
		$order->reduce_order_stock();

		// Remove cart
		$woocommerce->cart->empty_cart();

		// Return thankyou redirect
		return array(
			'result' 	=> 'success',
			'redirect'	=> add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('thanks'))))
		);
    }

}