Reputation: 1302
I want to edit my billing address at my website, where i need to add and delete some others in my account page, which code shall I edit?
Thank you in advanced
Upvotes: 3
Views: 6953
Reputation: 597
maybe the best way use woocommerce_default_address_fields
- is it ?
for example as
#5447232
add_filter( 'woocommerce_default_address_fields', 'add_MyNewOption_address' );
function add_MyNewOption_address( $fields ) {
$fields['MyNewOption'] = array(
'label' => __('Custom Field', 'woocommerce'), // Add custom field label
'placeholder' => _x('Custom Field', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('own-css-name') // add class name
);
return $fields;
}
Upvotes: 0
Reputation: 1302
To delete an existing field, country for example:
add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
function custom_override_billing_fields( $fields ) {
unset($fields['billing_country']);
return $fields;
}
Upvotes: 2
Reputation: 4870
Can you please check below code you can add new custom field example.
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
$fields['billing']['billing_options'] = array(
'label' => __('Custom Field', 'woocommerce'), // Add custom field label
'placeholder' => _x('Custom Field', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('own-css-name') // add class name
);
return $fields;
}
Upvotes: 3