を更新(あなたのコメントに関連した)...ここで
あなたもその場を作り、アドレス1フィールドから「アドレス」テキストラベルを削除し、アドレス2のフィールドに設定し追加を持っている(オプション)が必要と変更ちょっとしたプレースホルダー...もう一つの解決策もあります(コードの後ろを見てください)。ここで
コードです:あなたはフィールドの順序を変更する必要はありませんので、
add_filter('woocommerce_checkout_fields', 'custom_billing_fields_order');
function custom_billing_fields_order($fields) {
// 1. Customizing address_1 and address_2 fields
$fields['billing']['billing_address_1']['label'] = ''; // Removing the label from Adress1
$fields['billing']['billing_address_2']['label'] = __('Address', 'theme_domain');
$fields['billing']['billing_address_2']['required'] = true; // Making Address 2 field required
$fields['billing']['billing_address_2']['placeholder'] = __('Apartment, suite, unit etc...', 'woocommerce');
// 2. Custom ordering the billing fields array (toggling address_1 with address_2)
$custom_fields_order = array(
'billing_first_name', 'billing_last_name',
'billing_company',
'billing_email', 'billing_phone',
'billing_country',
'billing_address_2', 'billing_address_1', ## <== HERE, changed order
'billing_postcode', 'billing_city'
);
foreach($custom_fields_order as $field)
$new_ordered_fields[$field] = $fields['billing'][$field];
// Replacing original fields order by the custom one
$fields['billing'] = $new_ordered_fields;
// Returning Checkout customized billing fields order
return $fields;
}
代わりの2つのフィールドは、あなたがフィールドのプレースホルダを反転し、メイクを追加することができることをトグル(オプション)、アドレス2フィールドを必要としていました。あなたは、このようにそれを行うことができます。
add_filter('woocommerce_checkout_fields', 'custom_billing_fields_placeholders');
function custom_billing_fields_placeholders($fields) {
// 1. Customizing address_1 and address_2 fields
$fields['billing']['billing_address_1']['placeholder'] = __('Apartment, suite, unit etc...', 'woocommerce');
$fields['billing']['billing_address_2']['required'] = true; // Making Address 2 field required
$fields['billing']['billing_address_2']['placeholder'] = __('Street address', 'woocommerce');
// Returning Checkout customized billing fields
return $fields;
}
コードは、任意のプラグインファイルでも、あなたのアクティブな子テーマ(またはテーマ)のfunction.phpファイルになりますか。
コードがテストされ、動作します。
関連の答え:Checkout fields: Hiding and showing existing fields
公式ドキュメント:Customizing checkout fields using actions and filters
チェック[この回答](http://wordpress.stackexchange.com/questions/78339/how-to-reorder-billing- fields-in-woocommerce-checkout-template) –