Customizing my-account addresses fields in Woocommerce 3

后端 未结 2 532
太阳男子
太阳男子 2020-12-06 04:12

I would like to remove the form field billing_adress_2 within the template form-edit-addresses.php.

To finish is it possible to reorder the form fields likes this:<

2条回答
  •  无人及你
    2020-12-06 04:20

    This code will change the order of the fields in the billing address as you want them to appear. Place this code in your themes functions.php file.

    add_filter('woocommerce_address_to_edit', 'reorder_woocommerce_address_fields', 10, 2);
    
    function reorder_woocommerce_address_fields( $address, $load_address) {
        $new_address['billing_first_name'] = $address['billing_first_name'];
        $new_address['billing_last_name'] = $address['billing_last_name'];
        $new_address['billing_email'] = $address['billing_email'];
        $new_address['billing_phone'] = $address['billing_phone'];
    
        $new_address['billing_email'] = array(
            'label'     => __('Email', 'woocommerce'),
            'required'  => true,
            'class'     => array('form-row-first'),
        );
    
        $new_address['billing_phone'] = array(
            'label'     => __('Phone', 'woocommerce'),
            'required'  => true,
            'class'     => array('form-row-last'),
            'clear'     => true
        );
    
        $new_address['billing_company'] = $address['billing_company'];
        $new_address['billing_address_1'] = $address['billing_address_1'];
        $new_address['billing_postcode'] = $address['billing_postcode'];
        $new_address['billing_city'] = $address['billing_city'];
        $new_address['billing_state'] = $address['billing_state'];
    
        return $new_address;
    }
    

提交回复
热议问题