Commit dc3aad56f58 for woocommerce
commit dc3aad56f58c65bb7ee72662e3afb77dd5804ba9
Author: Luigi Teschio <gigitux@gmail.com>
Date: Tue Sep 8 09:37:20 2026 +0200
Fix saving unnamed products in the classic editor (#68427)
* Fix saving unnamed products in the classic editor
* Add changelog entry for unnamed product fix
* fix order
diff --git a/plugins/woocommerce/changelog/fix-33344-unnamed-product-save b/plugins/woocommerce/changelog/fix-33344-unnamed-product-save
new file mode 100644
index 00000000000..609340ac565
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-33344-unnamed-product-save
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Preserve product data when saving a new product without a name in the classic editor by using the default “(no title)” name.
diff --git a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
index b92a4a04aee..3fcf4f97230 100644
--- a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
+++ b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
@@ -55,6 +55,26 @@ jQuery( function ( $ ) {
}
} );
+ // WordPress discards empty auto-drafts before WooCommerce can save the product data.
+ const postForm = document.getElementById( 'post' );
+ if ( postForm ) {
+ postForm.addEventListener( 'formdata', function ( event ) {
+ const title = event.formData.get( 'post_title' );
+
+ if (
+ 'auto-draft' ===
+ event.formData.get( 'original_post_status' ) &&
+ typeof title === 'string' &&
+ '' === title.trim()
+ ) {
+ event.formData.set(
+ 'post_title',
+ woocommerce_admin_meta_boxes.i18n_no_title
+ );
+ }
+ } );
+ }
+
// Type box.
if ( $( 'body' ).hasClass( 'wc-wp-version-gte-55' ) ) {
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle' );
diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-assets.php b/plugins/woocommerce/includes/admin/class-wc-admin-assets.php
index 0f835ea87fb..f1c74f6d8ff 100644
--- a/plugins/woocommerce/includes/admin/class-wc-admin-assets.php
+++ b/plugins/woocommerce/includes/admin/class-wc-admin-assets.php
@@ -667,6 +667,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
+ 'i18n_no_title' => __( '(no title)', 'woocommerce' ),
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
'name_label' => __( 'Name', 'woocommerce' ),
'remove_label' => __( 'Remove', 'woocommerce' ),