在管理产品列上显示链式产品元

时间:2018-05-04 15:59:57

标签: wordpress woocommerce

我正在尝试在管理产品列上显示链式产品元,但它似乎只是显示数组。什么是虫子?谢谢你们!

// 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['chain_product'] = __( 'Custom','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;
		$chained_parent_id = empty( $variation ) ? $post->ID : $variation->ID;

    // HERE get the data from your custom field (set the correct meta key below)
    $chain_product = get_post_meta( $chained_parent_id, '_chained_product_detail', true );

    switch ( $column )
    {
        case 'chain_product' :
            echo $chain_product; // display the data
            break;
    }
}

0 个答案:

没有答案