Commit 90b9dd0bcd for woocommerce
commit 90b9dd0bcd2fd59c5dfef9edb23b159d30d02759
Author: Seun Olorunsola <30554163+triple0t@users.noreply.github.com>
Date: Tue Feb 3 08:06:39 2026 +0100
Fix: Empty email subject for "Order Refunded" (partially refunded) email in block editor (#63047)
* Enhance email functionality for partially refunded orders
- Added a new text display in the email editor for the 'customer_partially_refunded_order' type, guiding users to update email configurations.
- Implemented a method to retrieve the email subject for partially refunded orders, allowing for personalized content.
- Updated the email settings schema to support additional subject fields for better customization of email notifications.
* Add changefile(s) from automation for the following project(s): woocommerce, woocommerce/client/admin
* Fix lint and phpstan errors
* Update email configuration text for clarity in sidebar settings
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/63047-stomail-7771-order-refunded-email-subject-is-empty b/plugins/woocommerce/changelog/63047-stomail-7771-order-refunded-email-subject-is-empty
new file mode 100644
index 0000000000..39aa6a045f
--- /dev/null
+++ b/plugins/woocommerce/changelog/63047-stomail-7771-order-refunded-email-subject-is-empty
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix empty email subject for "Partially refunded order" email in the block email editor by properly retrieving the subject_partial option.
\ No newline at end of file
diff --git a/plugins/woocommerce/client/admin/client/wp-admin-scripts/email-editor-integration/sidebar_settings.tsx b/plugins/woocommerce/client/admin/client/wp-admin-scripts/email-editor-integration/sidebar_settings.tsx
index e7419e4330..36f1374d7b 100644
--- a/plugins/woocommerce/client/admin/client/wp-admin-scripts/email-editor-integration/sidebar_settings.tsx
+++ b/plugins/woocommerce/client/admin/client/wp-admin-scripts/email-editor-integration/sidebar_settings.tsx
@@ -8,6 +8,7 @@ import {
PanelRow,
TextControl,
ToggleControl,
+ __experimentalText as Text,
} from '@wordpress/components';
import { addFilter } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';
@@ -82,6 +83,24 @@ const SidebarSettings = ( {
const previewTextLength = woocommerce_email_data?.preheader?.length ?? 0;
+ if (
+ woocommerce_email_data.email_type ===
+ 'customer_partially_refunded_order'
+ ) {
+ return (
+ <>
+ <br />
+ <Text>
+ { __(
+ 'Update this email configuration in the "Order refunded" email.',
+ 'woocommerce'
+ ) }
+ </Text>
+ <br />
+ </>
+ );
+ }
+
return (
<>
<br />
diff --git a/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php b/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
index 2efaa4b7b8..9fb91d82de 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
@@ -68,6 +68,42 @@ if ( ! class_exists( 'WC_Email_Customer_Partially_Refunded_Order', false ) ) :
)
);
}
+
+ /**
+ * Get email subject.
+ *
+ * @return string
+ */
+ public function get_subject() {
+ $subject = $this->get_option( 'subject_partial', $this->get_default_subject( true ) );
+ /**
+ * Filter the email subject for customer refunded order.
+ *
+ * @param string $subject The email subject.
+ * @param object|bool $order Order object.
+ * @param WC_Email_Customer_Refunded_Order $email Email object.
+ * @since 3.7.0
+ */
+ $subject = apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
+ if ( $this->block_email_editor_enabled ) {
+ $subject = $this->personalizer->personalize_transactional_content( $subject, $this );
+ }
+ return $subject;
+ }
+
+ /**
+ * Return the name of the option in the WP DB.
+ *
+ * @since 2.6.0
+ * @return string
+ */
+ public function get_option_key() {
+ $id = 'customer_refunded_order';
+ // we need to continue using the parent class's id because we want to maintain backwards compatibility
+ // and allow the parent class continue managing the settings options for this class.
+ // We can remove this once we have migrated all the settings options to this class.
+ return $this->plugin_id . $id . '_settings';
+ }
}
endif;
diff --git a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Settings/Emails/Schema/EmailsSettingsSchema.php b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Settings/Emails/Schema/EmailsSettingsSchema.php
index accad58a16..d0a4cf7075 100644
--- a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Settings/Emails/Schema/EmailsSettingsSchema.php
+++ b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Settings/Emails/Schema/EmailsSettingsSchema.php
@@ -37,7 +37,7 @@ class EmailsSettingsSchema extends AbstractSchema {
*
* @var array
*/
- const FIELDS_SUPPORTING_PERSONALIZATION_TAGS = array( 'subject', 'preheader' );
+ const FIELDS_SUPPORTING_PERSONALIZATION_TAGS = array( 'subject', 'preheader', 'subject_full', 'subject_partial' );
/**
* Personalization tags registry.
@@ -291,6 +291,19 @@ class EmailsSettingsSchema extends AbstractSchema {
}
$values[ $id ] = $value;
+
+ // Handle customer_refunded_order email type because it has two different subjects.
+ if ( 'customer_refunded_order' === $email->id && 'subject_full' === $id ) {
+ if ( ! isset( $values['subject'] ) ) {
+ $values['subject'] = $value;
+ }
+ }
+
+ if ( 'customer_partially_refunded_order' === $email->id && 'subject_partial' === $id ) {
+ if ( ! isset( $values['subject'] ) ) {
+ $values['subject'] = $value;
+ }
+ }
}
return $values;