Viewing 2 replies - 1 through 2 (of 2 total)
  • You need to save the information in order metadata to be able to see it.

    Something like that

    add_action( 'woocommerce_checkout_update_order_meta', 'my_write_to_meta_function' );
    
    function my_write_to_meta_function( $order_id ) {
    update_post_meta($order_id, "order_meta_field", sanitize_text_field($_POST["my_field_name"]));
    }
    Thread Starter Stefan Velev

    (@kozzmen)

    I am confused because of this paragraph just under the picture in the tutorial

    Now we have this new field, what do we do with it? We don’t need to do anything! Because we’re defined the field in the checkout_fields array the field will be automatically processed and saved to the order post meta (in this case the field will be _shipping_phone). If you want to add extra validation rules see the checkout class; there are additional hooks in there you can use.

    Anyway, thanks for the snippet kingturban, I will give it a try.

    P.S. What should I use instead of “my_write_to_meta_function”?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a custom shipping field’ is closed to new replies.