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:
@@ -1295,8 +1295,8 @@ class OrdersController {
|
|||||||
$value = $term ? $term->name : $value;
|
$value = $term ? $term->name : $value;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Custom attribute - WooCommerce stores as 'attribute_' + exact attribute name
|
// Custom attribute - WooCommerce stores as 'attribute_' + lowercase sanitized name
|
||||||
$meta_key = 'attribute_' . $attr_name;
|
$meta_key = 'attribute_' . sanitize_title( $attr_name );
|
||||||
$value = get_post_meta( $variation_id, $meta_key, true );
|
$value = get_post_meta( $variation_id, $meta_key, true );
|
||||||
|
|
||||||
// Capitalize the attribute name for display
|
// Capitalize the attribute name for display
|
||||||
|
|||||||
Reference in New Issue
Block a user