con
(@conschneider)
Engineer
Hi there,
Since WooCommerce has no built in feature to display the attributes as admin columns, I reckon that very much depends on how you facilitate this. How do you add the admin attribute columns?
WooCommerce store the attribute information as post meta.
Kind regards,
Thread Starter
liguru
(@liguru)
I use this code:
// ADDING A CUSTOM COLUMN TITLE TO ADMIN PRODUCTS LIST
add_filter( ‘manage_edit-product_columns’, ‘custom_product_column’,11);
function custom_product_column($columns)
{
//add columns
$columns[‘delivery’] = __( ‘Atributai’,’woocommerce’); // title
return $columns;
}
// ADDING THE DATA FOR EACH PRODUCTS BY COLUMN (EXAMPLE)
add_action( ‘manage_product_posts_custom_column’ , ‘custom_product_list_column_content’, 10, 2 );
function custom_product_list_column_content( $column, $product_id )
{
global $post;
// HERE get the data from your custom field (set the correct meta key below)
$atributai = get_post_meta( $product_id, ‘_product_attributes’, true );
switch ( $column )
{
case ‘delivery’ :
print_r($atributai[‘pa_sandelys’][‘value’]);
break;
}
}
get_post_meta( $product_id, ‘_product_attributes’, true ); is likely the incorrect part.
Try getting the product object and then attributes from that. So:
$product = wc_get_product( $product_id );
$atributai = $product->get_attributes();
This isn’t something we can support though, as it’s not a core feature of the plugin. If you can’t figure out the code you need and this is something you must have, I recommend hiring a developer:
– http://jobs.wordpress.net/
– https://codeable.io/
– https://woocommerce.com/experts/