Für WooCommerce 3+ (Update):
Seit WooCommerce 3.0 Kasse Felder ein wenig verändert haben, ist so nicht möglich, Felder neu anordnen wie zuvor.
Es gibt eine neue ‚Priorität‘ Argument die Felder behandeln bestellen, für Kasse Felder und mein Konto Felder als auch.
Below Ich bin Aktualisierung nur den Teil im Zusammenhang mit der Bestellung Felder:
## 3. Ordering the billing fields
// Set the order of the fields
$billing_fields_new_order = array(
'billing_first_name', 'billing_last_name', 'billing_status',
'billing_email', 'billing_phone', 'billing_serial_id',
'billing_custom1', 'billing_custom2', 'billing_custom3',
'billing_company', 'billing_address_1', 'billing_address_2',
'billing_postcode', 'billing_city', 'billing_country',
);
$count = 0;
$priority = 10;
// Updating the 'priority' argument
foreach($billing_fields_new_order as $field_name){
$count++;
$fields['billing'][$field_name]['priority'] = $count * $priority;
}
// END: returning the customized checkout fields
return $fields;
Referenz:Reordering checkout fields in WooCommerce 3
Ursprüngliche Antwort:
Sie müssen verwenden woocommerce_checkout_fields
Haken. Dann erstellen Sie zuerst die neuen Felder. Nach Anpassen einiger Feldklassen. Um das Feld nach Ihrem Wunsch neu zu ordnen. Hier
ist der Code:
add_filter('woocommerce_checkout_fields', 'custom_checkout_billing_fields');
function custom_checkout_billing_fields($fields) {
// 1. Creating the additional custom billing fields
// The "status" selector
$fields['billing']['billing_status']['type'] = 'select';
$fields['billing']['billing_status']['class'] = array('form-row-wide, status-select');
$fields['billing']['billing_status']['required'] = true;
$fields['billing']['billing_status']['label'] = __('User status', 'my_theme_slug');
$fields['billing']['billing_status']['placeholder'] = __('Chose an option', 'my_theme_slug');
$fields['billing']['billing_status']['options'] = array(
'' => 'Chose an option',
'1' => 'Legal entity',
'2' => 'Individual'
);
// The "Serial ID" text field
$fields['billing']['billing_serial_id']['type'] = 'text';
$fields['billing']['billing_serial_id']['class'] = array('form-row-wide', 'status-group1');
$fields['billing']['billing_serial_id']['required'] = true;
$fields['billing']['billing_serial_id']['label'] = __('Serial ID', 'my_theme_slug');
$fields['billing']['billing_serial_id']['placeholder'] = __('Enter your Serial ID', 'my_theme_slug');
// The "Custom 1" text field
$fields['billing']['billing_custom1']['type'] = 'text';
$fields['billing']['billing_custom1']['class'] = array('form-row-wide', 'status-group2');
$fields['billing']['billing_custom1']['required'] = true;
$fields['billing']['billing_custom1']['label'] = __('Custom name 1', 'my_theme_slug');
$fields['billing']['billing_custom1']['placeholder'] = __('Enter your custom1', 'my_theme_slug');
// The "Custom 2" text field
$fields['billing']['billing_custom2']['type'] = 'text';
$fields['billing']['billing_custom2']['class'] = array('form-row-wide', 'status-group2');
$fields['billing']['billing_custom2']['required'] = true;
$fields['billing']['billing_custom2']['label'] = __('Custom name 2', 'my_theme_slug');
$fields['billing']['billing_custom2']['placeholder'] = __('Enter your custom2', 'my_theme_slug');
// The "Custom 3" text field
$fields['billing']['billing_custom3']['type'] = 'text';
$fields['billing']['billing_custom3']['class'] = array('form-row-wide', 'status-group2');
$fields['billing']['billing_custom3']['required'] = true;
$fields['billing']['billing_custom3']['label'] = __('Custom name 3', 'my_theme_slug');
$fields['billing']['billing_custom3']['placeholder'] = __('Enter your custom3', 'my_theme_slug');
// 2. Customizing 'billing_email' and 'billing_phone' fields ['class']
$fields['billing']['billing_email']['class'] = array('form-row-first', 'status-group1');
$fields['billing']['billing_phone']['class'] = array('form-row-last', 'status-group1');
// 3. Ordering the billing fields
$fields_order = array(
'billing_first_name', 'billing_last_name', 'billing_status',
'billing_email', 'billing_phone', 'billing_serial_id',
'billing_custom1', 'billing_custom2', 'billing_custom3',
'billing_company', 'billing_address_1', 'billing_address_2',
'billing_postcode', 'billing_city', 'billing_country',
);
foreach($fields_order as $field) $ordered_fields[$field] = $fields['billing'][$field];
$fields['billing'] = $ordered_fields;
// Returning Checkout customized billing fields
return $fields;
}
Natürlich geht so auf function.php Datei Ihrer aktiven Kind Thema oder Thema
Dieser Code ist getestet und voll funktionsfähig.
Jetzt mit diesem Code kann yo eine Frage stellt den „bedingten“ Teil dieser Frage zu behandeln (wie ich Ihnen in den Kommentaren habe sagen) ...
Offizielle Referenz: WooThemes - Customizing checkout fields using actions and filters
nachdem der Benutzer den Nachnamen vervollständigen wird. die Struktur ist wie folgt: - erste nennen - Nachname - Status der Person a) juristische Person: b) einzelne wenn es a), wird sich zeigen: Telefonnummer, E-Mail und Serien ID wenn es b) wird angezeigt: andere 3 Felder und danach die klassischen Felder. –
Da Ihre Frage zu weit gefasst ist, würde ich nur helfen, wenn Sie Ihre Fragen teilen: Teil 1 (JETZT) Erstellen der neuen Kasse benutzerdefinierte Rechnungsfelder und Neuordnen Rechnungsfelder (um zu entsprechen, was Sie wollen) ... Dann (AFTER) auf eine andere Frage : Machen Sie den bedingten Teil (der jQuery (javascript) und vielleicht ajax benötigt). Also bitte bearbeiten Sie Ihre Frage Um nur Teil 1 zu haben – LoicTheAztec
Ich muss den Checkout-Prozess für eine Woocommere-Website ändern. Der Prozess wird durch den Status der Person bestimmt, die eine davon sein könnte: - 'legal entity' - 'individual' Ich brauche einen Selektor 'Benutzerstatus' (oder Optionsfelder), direkt nach dem ' abrechnungs erster_name und abrechnung_letzter_name Der Wähler sollte so funktionieren: Wenn ‚juristische Person‘ ausgewählt wird, soll es drei Felder angezeigt werden: ‚phone_number‘ ‚E-Mail‘ ‚SERIAL_ID‘ –