wc_order_fully_refunded( int $order_id )

When refunding an order, create a refund line item if the partial refunds do not match order total.

Description Description

This is manual; no gateway refund will be performed.

Parameters Parameters


(Required) Order ID.

Top ↑

Source Source

File: includes/wc-order-functions.php

function wc_order_fully_refunded( $order_id ) {
	$order      = wc_get_order( $order_id );
	$max_refund = wc_format_decimal( $order->get_total() - $order->get_total_refunded() );

	if ( ! $max_refund ) {

	// Create the refund object.
			'amount'     => $max_refund,
			'reason'     => __( 'Order fully refunded.', 'woocommerce' ),
			'order_id'   => $order_id,
			'line_items' => array(),

	$order->add_order_note( __( 'Order status set to refunded. To return funds to the customer you will need to issue a refund through your payment gateway.', 'woocommerce' ) );

Top ↑

Changelog Changelog

Version Description
2.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.