From a2bf32d416de70c250c5b89457566a2349cddc9d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 12 Dec 2012 15:55:19 +0000 Subject: [PATCH] Order refund #1755. --- classes/class-wc-order.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index 4df558d8370..39edb829eca 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -1261,6 +1261,20 @@ class WC_Order { * @return void */ function refund_order( $use_gateway = false ) { + $total_to_refund = woocommerce_format_total( $this->get_total() - $this->get_refund_total() ); + + if ( $use_gateway ) { + + // Trigger an action which the gateway can pick up to do the refund - the gateway needs to handle status updates and setting the refunded total. + do_action( 'woocommerce_' . sanitize_title( $this->payment_method ) . '_refund_order', $this->id, $total_to_refund ); + + } else { + + update_post_meta( $this->id, '_refund_total', $this->get_total() ); + + $this->update_status( 'refunded', sprintf( __( 'Order refunded manually.', 'woocommerce' ) ) ); + + } }