• Resolved atmadja

    (@atmadja)


    Hello guys,
    First thank you for this plugin which is very helpfull for me.

    I’m a begginer in developping, but I’m trying to display WCFF fields on woocommerce backoffice orders page, to achieve a better reading of what orders contain.

    For that, here is the code I work on, which I put in functions.php.
    I’m able to display a new column in which I’m able to insert product description for example. But I didn’t find how to get my WCFF fileds to be displayed here.

    Here is my code :

    <?php
    // Add a new custom column to admin order list
    add_filter( 'manage_edit-shop_order_columns', 'admin_orders_list_add_column', 10, 1 );
    function admin_orders_list_add_column( $columns ){
        $columns['custom_column'] = __( 'New Column', 'woocommerce' );
    
        return $columns;
    }
    
    // The data of the new custom column in admin order list
    add_action( 'manage_shop_order_posts_custom_column' , 'admin_orders_list_column_content', 10, 2 );
    function admin_orders_list_column_content( $column, $post_id ){
        global $the_order;
    
        if( 'custom_column' === $column ){
            $count = 0;
    
            // Loop through order items
            foreach( $the_order->get_items() as $item ) {
                $product = $item->get_product(); // The WC_Product Object
                $style   = $count > 0 ? ' style="padding-left:6px;"' : '';
            	$meta0   = $product->get_meta_data();
    
                // Display product description, but I want to display my WCFF fields here
            	printf($product->get_description());
    
    
                $count++;
            }
        }
    }
    ?>

    Can you help me finding how to catch the fields to display them please ?

Viewing 1 replies (of 1 total)
  • Thread Starter atmadja

    (@atmadja)

    Edit : I found the solution.

    Here is the code I use :

    // Add a new custom column to admin order list
    add_filter( 'manage_edit-shop_order_columns', 'admin_orders_list_add_column', 10, 1 );
    function admin_orders_list_add_column( $columns ){
        $columns['custom_column'] = __( 'New Column', 'woocommerce' );
    
        return $columns;
    }
    
    // The data of the new custom column in admin order list
    add_action( 'manage_shop_order_posts_custom_column' , 'admin_orders_list_column_content', 10, 2 );
    function admin_orders_list_column_content( $column, $post_id ){
        global $the_order;
    
        if( 'custom_column' === $column ){
            $count = 0;
    
            // Loop through order items
            foreach( $the_order->get_items() as $item_id => $item ) {
            	$allmeta = $item->get_meta_data();
            	$somemeta = $item->get_meta( 'Plat', true );
    
                // Display order meta data
            	//print_r($allmeta);
            	print_r($somemeta);
    
                $count++;
            }
        }
    }

    If someone need, the meta key (in my case “Plat”) can be found here :

    Hope this post will help you.
    Thanks community.

Viewing 1 replies (of 1 total)

The topic ‘display WCFF field on backoffice orders page’ is closed to new replies.