Refunds can be a sore subject but it is something that every store has to deal with, keeping track of refund reasons can be very beneficial to you so you can keep pushing your refund rate down further and further.
The problem is that you do not always want your customer to see the reason you enter for when doing a refund, which WooCommerce will display by default to each customer.
Good news is that you can easily replace the refund reason in your customer-facing emails and pages with static text like just “Refund”.
Add the following code to end of your theme’s functions.php file omitting the opening <?php tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace refund reason with generic Refund text. | |
* | |
* @param $total_rows | |
* @param $order | |
* @param $tax_display | |
* @return array | |
*/ | |
function remove_public_facing_refund_reason( $total_rows, $order, $tax_display ) { | |
foreach ( $total_rows as $id => $row ) { | |
if ( false !== stripos( $id, 'refund_' ) ) { | |
$total_rows[ $id ]['label'] = __( 'Refund' ); | |
} | |
} | |
return $total_rows; | |
} | |
add_filter( 'woocommerce_get_order_item_totals', 'remove_public_facing_refund_reason', 10, 3 ); |
I copy-pasted this PHP snippet in my child theme’s functions.php file. Works perfectly in WooCommerce version 4.1.0. Thank you for sharing!
0 Pingbacks