fix(api): normalize custom attribute meta key to lowercase

WooCommerce stores variation custom attribute meta keys in lowercase
(e.g., attribute_size), but we were using the original case from
parent attributes (e.g., attribute_Size). This caused empty attribute
values in the admin Order Form variation selector.

Fix: Use sanitize_title() to normalize the attribute name.
This commit is contained in:
Dwindi Ramadhana
2026-01-08 09:19:08 +07:00
parent a0e580878e
commit 687e51654b

View File

@@ -1295,8 +1295,8 @@ class OrdersController {
$value = $term ? $term->name : $value;
}
} else {
// Custom attribute - WooCommerce stores as 'attribute_' + exact attribute name
$meta_key = 'attribute_' . $attr_name;
// Custom attribute - WooCommerce stores as 'attribute_' + lowercase sanitized name
$meta_key = 'attribute_' . sanitize_title( $attr_name );
$value = get_post_meta( $variation_id, $meta_key, true );
// Capitalize the attribute name for display