diff --git a/admin-spa/src/routes/Products/index.tsx b/admin-spa/src/routes/Products/index.tsx index 994b3ef..33b852c 100644 --- a/admin-spa/src/routes/Products/index.tsx +++ b/admin-spa/src/routes/Products/index.tsx @@ -88,6 +88,8 @@ export default function Products() { order, }), placeholderData: keepPreviousData, + staleTime: 0, // Always fetch fresh data + gcTime: 0, // Don't cache }); // Fetch categories for filter diff --git a/includes/Api/ProductsController.php b/includes/Api/ProductsController.php index a5cb82d..715668e 100644 --- a/includes/Api/ProductsController.php +++ b/includes/Api/ProductsController.php @@ -579,16 +579,28 @@ class ProductsController { // Format attributes with human-readable names and values $formatted_attributes = []; - foreach ($variation->get_attributes() as $attr_name => $attr_value) { - // Remove 'pa_' prefix if present (for global attributes) - $clean_name = str_replace('pa_', '', $attr_name); - // Capitalize first letter - $clean_name = ucfirst($clean_name); - // Get term name if it's a taxonomy - if (taxonomy_exists($attr_name)) { - $term = get_term_by('slug', $attr_value, $attr_name); - $attr_value = $term ? $term->name : $attr_value; + $variation_attributes = $variation->get_attributes(); + + // Debug: Log raw variation attributes + error_log('WooNooW Debug - Variation #' . $variation_id . ' raw attributes: ' . print_r($variation_attributes, true)); + + foreach ($variation_attributes as $attr_name => $attr_value) { + // Handle taxonomy attributes (pa_*) + if (strpos($attr_name, 'pa_') === 0) { + // Global attribute + $taxonomy = $attr_name; + $clean_name = wc_attribute_label($taxonomy); + + if (!empty($attr_value)) { + $term = get_term_by('slug', $attr_value, $taxonomy); + $attr_value = $term ? $term->name : $attr_value; + } + } else { + // Custom attribute + $clean_name = ucfirst(str_replace('_', ' ', $attr_name)); + // For custom attributes, the value is already the display value } + $formatted_attributes[$clean_name] = $attr_value; }