Support » Plugin: WooCommerce » Adding Custom Meta Data from Products to Orders

  • Carl


    I’m trying to get the Custom Meta data of my woocommerce products to my Order Columns in my Woocommerce Admin but this code wont work on my function.php in WordPress Theme.

    // Add the the product custom field as item meta data in the order
    add_action( 'woocommerce_add_order_item_meta', 'pd_number_order_meta_data', 10, 3 );
    function pd_number_order_meta_data( $item_id, $cart_item, $cart_item_key ) {
        // get the product custom field value
        $pd_number = get_post_meta( $cart_item[ 'product_id' ], '_pd_number', true );
        // Add the custom field value to order item meta
        if( ! empty($pd_number) )
            wc_update_order_item_meta( $item_id, '_pd_number', $pd_number );


  • The topic ‘Adding Custom Meta Data from Products to Orders’ is closed to new replies.