Order refund #1755.

This commit is contained in:
Mike Jolley 2012-12-12 15:55:19 +00:00
parent fd8e15bbea
commit a2bf32d416
1 changed files with 14 additions and 0 deletions

View File

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