• Resolved j4quinn

    (@j4quinn)


    I am trying to find a hook to allow the addition of a custom field to the orders billing/shipping address on the orders page in the admin section.

    For instance, documentation mentions the hook woocommerce_admin_order_data_after_shipping_address, however, i want to actually add, for instance, a neighbour checkout field to the address portion not after the shippping address. So, as stated above, what hook could i use for this?

    Thanks in advance,

Viewing 6 replies - 1 through 6 (of 6 total)
  • AJ a11n

    (@amandasjackson)

    Hi there,

    It sounds like you are wanting to add a custom field to the checkout page and have the information entered into that field at checkout (by the customer) show in the Order on the admin side. Is my understanding correct?

    If so, here’s a link to a post that includes coding to achieve both (adding the field to the checkout on the front end, and also displaying this information on the order in the backend:

    https://www.cloudways.com/blog/custom-field-woocommerce-checkout-page/

    There is also a plugin that will do this as well:

    https://woocommerce.com/products/woocommerce-checkout-field-editor/

    Thread Starter j4quinn

    (@j4quinn)

    Thanks,

    Yes, and no. I have already added a checkout field, for instance, neighbourhood.

    Now the issue is adding this field on the orders page in the admin section with the actual address. I do not want to append to the end like the hook woocommerce_admin_order_data_after_shipping_address would do.

    Any idea how to proceed?

    PS>
    I do not want to work with a plugin as they require purchasing at some point.

    • This reply was modified 5 years, 5 months ago by j4quinn.
    AJ a11n

    (@amandasjackson)

    Hi @j4quinn

    The post I linked above has code for Displaying the custom field in the admin order:

    https://www.cloudways.com/blog/custom-field-woocommerce-checkout-page/#WooCommerce-Display-Field

    add_action( 'woocommerce_admin_order_data_after_shipping_address', 'edit_woocommerce_checkout_page', 10, 1 );
    
    function edit_woocommerce_checkout_page($order){
        global $post_id;
        $order = new WC_Order( $post_id );
        echo '<p><strong>'.__('Field Value').':</strong> ' . get_post_meta($order->get_id(), '_shipping_field_value', true ) . '</p>';
    }
    • This reply was modified 5 years, 5 months ago by AJ a11n.
    Thread Starter j4quinn

    (@j4quinn)

    Yes, but as i stated, i do not want to append after the shipping address as that hook does. I want to add the field with the address.

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    Yes, but as i stated, i do not want to append after the shipping address as that hook does. I want to add the field with the address.

    Since we are talking layout here it would be helpful to see this. Can you upload a screenshot that illustrates this and post the link here.

    Kind regards,

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Kind regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding new field to billing/shipping address under orders page in admin’ is closed to new replies.