Default Woocommerce placeholder not submitted to order form
I am using woocommerce_checkout_fields to change labels and fields. Below is my code
function custom_override_checkout_fields($fields) {
$fields['billing']['billing_first_name'] = array(
'label' => '',
'placeholder' => _x('First Name*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-first-name')
);
$fields['billing']['billing_last_name'] = array(
'label' => '',
'placeholder' => _x('last Name*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-last-name')
);
$fields['billing']['billing_company'] = array(
'label' => '',
'placeholder' => _x('Company Name', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('checkout-billing-company')
);
$fields['billing']['billing_address_1'] = array(
'label' => '',
'placeholder' => _x('Address(Line 1)*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-addressL1')
);
$fields['billing']['billing_address_2'] = array(
'label' => '',
'placeholder' => _x('Address(Line 2)*', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('checkout-billing-addressL2')
);
return $fields;
}
add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields');
Everything works fine, but the placeholder for billing address 1 and billing address 2 only change when loading ie after page load, default readings are shown.
+3
source to share
2 answers
Try using the woocommerce_default_address_fields filter.
For example:
function pawelprotas_wc_default_address_fields($fields){
$fields['address_1']['placeholder'] = __('Street address *', 'loft');
$fields['address_2']['placeholder'] = __('Apartment, suite, unit etc.', 'loft');
return $fields;
}
add_filter('woocommerce_default_address_fields', 'pawelprotas_wc_default_address_fields');
+2
source to share