WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Need to add "Additional Info" field during checkout ( (1 post)

  1. Rohan
    Member
    Posted 1 year ago #

    Hi,

    I am using this plugin for my website. I have used hook to add a custom field "Additional Info" which will will allow to leave some details that they want during the shipping. But, Problem is that the changes are not reflected in backend. ie when user fills this field and orders any product, in backend it is not reflected in "Customer Note:" section.
    Any help will be much appreciated. Also, is there any way to display "Customer Note:" section on frontend while checkout, so that there is no need to add hooks

    add_action('woocommerce_after_checkout_billing_form', 'my_custom_checkout_field');
    
    function my_custom_checkout_field( $checkout ) {
    
        woocommerce_form_field( 'my_field_name', array(
            'type'          => 'textarea',
            'class'         => array('form-row-first'),
            'label'         => __('Comments'),
            'placeholder'       => __('Enter something'),
            ), $checkout->get_value( 'my_field_name' ));
    
    } 
    
    add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
    
    function my_custom_checkout_field_update_order_meta( $order_id ) {
        if ($_POST['my_field_name']) update_post_meta( $order_id, 'My Field', esc_attr($_POST['my_field_name']));
    }

    http://wordpress.org/extend/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic