• Resolved liguru

    (@liguru)


    Hello,

    having issue with woocommerce product attribute displaying. In admin backend product listing custom column i’m displaying product attributes – attached link of the screenshot.

    But after updating product attributes – they’re missing in this column, but in frontend (in e-shop) and in product editing window – attributes are visible.

    I checked database tables for these products – and attributes are empty there too. Where does WordPress store values of product attributes? And why they become empty after editing?

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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;
    }
    }

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    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/

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Woocommerce product attributes’ is closed to new replies.