function aggiungi_colonna_attributi($columns) {
$columns['attributi'] = 'Attributi';
return $columns;
}
add_filter('manage_edit-product_columns', 'aggiungi_colonna_attributi');
// Popola la colonna degli attributi con i dati
function popola_colonna_attributi($column, $post_id) {
if ($column == 'attributi') {
$product = wc_get_product($post_id);
$attributes = $product->get_attributes();
if (!empty($attributes)) {
foreach ($attributes as $attribute) {
$attribute_name = wc_attribute_label($attribute->get_name());
if ($attribute->is_taxonomy()) {
$attribute_values = wc_get_product_terms($post_id, $attribute->get_name(), array('fields' => 'names'));
$attribute_options = implode(', ', $attribute_values);
} else {
$attribute_options = implode(', ', $attribute->get_options());
}
echo '<p><strong>' . esc_html($attribute_name) . ':</strong> ' . esc_html($attribute_options) . '</p>';
}
} else {
echo '-';
}
}
}
add_action('manage_product_posts_custom_column', 'popola_colonna_attributi', 10, 2);
Copia il codice nel file functions.php del tuo tema child attivo o utilizza il plugin Code Snippets.