Commit 21d934739af for woocommerce
commit 21d934739af523f014387163f6bc1331ead79175
Author: Anuj Singh <80690679+Anuj-Rathore24@users.noreply.github.com>
Date: Tue Jul 14 19:33:21 2026 +0530
Free Shipping method name duplicated in shipping amount cell (#66034)
* Fix: Fix Free Shipping method name duplicated in shipping amount cell
* feat: Add test for get_shipping_to_display() Free Shipping fix.
* refactor: Update issue number
* feat: Fix Free Shipping name duplicated in email with improvements enabled
- Scope the fix to the email_improvements surface only. The original change to get_shipping_to_display() was too broad
- Instead, override `add_order_item_totals_shipping_row()` in WC_Order, post-processing the shipping row value to show "Free" only when email_improvements is enabled and the shipping total is zero.
* feat: Update tests to reflect scoped email_improvements fix
* refactor: Wraps test logic in with `try...finally` block
* refactor: simplify zero check and drop redundant method validation
* feat: Move fix to email templates instead of order class.
* refactor: Update changelog
* refactor: Remove unit tests for the reverted order class approach
* refactor: Remove unused FeaturesController import
* Bump email order details template versions to 11.1.0
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Ján Mikláš <neosinner@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/fix-free-shipping-method-name-duplicated-in-shipping-amount b/plugins/woocommerce/changelog/fix-free-shipping-method-name-duplicated-in-shipping-amount
new file mode 100644
index 00000000000..a06d34af27d
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-free-shipping-method-name-duplicated-in-shipping-amount
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix Free Shipping method name duplicated in order emails with improvements enabled
diff --git a/plugins/woocommerce/templates/emails/email-order-details.php b/plugins/woocommerce/templates/emails/email-order-details.php
index 33f63012399..73a232af6f0 100644
--- a/plugins/woocommerce/templates/emails/email-order-details.php
+++ b/plugins/woocommerce/templates/emails/email-order-details.php
@@ -12,7 +12,7 @@
*
* @see https://woocommerce.com/document/template-structure/
* @package WooCommerce\Templates\Emails
- * @version 10.8.0
+ * @version 11.1.0
*/
use Automattic\WooCommerce\Utilities\FeaturesUtil;
@@ -152,6 +152,10 @@ endif;
foreach ( $item_totals as $total ) {
++$i;
$last_class = ( $i === $item_totals_count ) ? ' order-totals-last' : '';
+ // The shipping method name is already shown in the row header, so avoid duplicating it in the value cell.
+ if ( $email_improvements_enabled && isset( $total['meta'] ) && $total['value'] === $total['meta'] ) {
+ $total['value'] = __( 'Free', 'woocommerce' );
+ }
?>
<tr class="order-totals order-totals-<?php echo esc_attr( $total['type'] ?? 'unknown' ); ?><?php echo esc_attr( $last_class ); ?>">
<th class="td text-align-left" scope="row" colspan="2" style="<?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>">
diff --git a/plugins/woocommerce/templates/emails/plain/email-order-details.php b/plugins/woocommerce/templates/emails/plain/email-order-details.php
index d2d76a1e8b7..7709b1f9429 100644
--- a/plugins/woocommerce/templates/emails/plain/email-order-details.php
+++ b/plugins/woocommerce/templates/emails/plain/email-order-details.php
@@ -12,7 +12,7 @@
*
* @see https://woocommerce.com/document/template-structure/
* @package WooCommerce\Templates\Emails
- * @version 10.8.0
+ * @version 11.1.0
*/
use Automattic\WooCommerce\Utilities\FeaturesUtil;
@@ -64,6 +64,10 @@ $item_totals = $order->get_order_item_totals();
if ( $item_totals ) {
foreach ( $item_totals as $total ) {
if ( $email_improvements_enabled ) {
+ // The shipping method name is already shown in the row header, so avoid duplicating it in the value cell.
+ if ( isset( $total['meta'] ) && $total['value'] === $total['meta'] ) {
+ $total['value'] = __( 'Free', 'woocommerce' );
+ }
$label = $total['label'];
if ( isset( $total['meta'] ) ) {
$label .= ' ' . $total['meta'];