Saturday, 8 June 2013

Display each custom field value saved in array on woocommerce

Display each custom field value saved in array on woocommerce

This probably sounds similiar, but i have not found a solution for it. I'm using woocommerce and want to display each custom field value saved in a array.
i have this function that updated each value from the checkout field and saved it under "My Field"
function custom_checkout_field_update_order_meta( $order_id ) {

    if ( $_POST['field_name'])
 update_post_meta( $order_id, 'My Field', esc_attr($_POST['field_name']));
}
add_action('woocommerce_checkout_update_order_meta',    'custom_checkout_field_update_order_meta');
i would like to print out each value that was updated. I am unsure where woocommerce stores the values, and how to get_post_meta.
I have also came up with
function custom_print_each_field() {
global $woocommerce;

$text_string = get_post_meta( get_the_ID(), 'My Field', true );
foreach ($text_string as $single ) :
echo $single;
endforeach;
}
but it does not work :( hoping someone can help me.

No comments:

Post a Comment