2016-08-23 11 views
0

ich die Auftragsfelder auf der WooCommerce Kasse Seite mit dieser Funktion neu geordnet habe:WooCommerce neu anordnen Kasse Felder

//Reorder checkout 
    add_filter('woocommerce_checkout_fields', 'reorder_woo_fields'); 
    function reorder_woo_fields($fields) { 
    $fields2['billing']['billing_first_name'] = $fields['billing'] ['billing_first_name']; 
    $fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name']; 
    $fields2['billing']['billing_company'] = $fields['billing']['billing_company']; 
    $fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1']; 
    $fields2['billing']['billing_city']  = $fields['billing']['billing_city']; 
    $fields2['billing']['billing_postcode'] = $fields['billing']['billing_postcode']; 
    $fields2['billing']['billing_country'] = $fields['billing']['billing_country']; 
    $fields2['billing']['billing_email']  = $fields['billing']['billing_email']; 
    $fields2['billing']['billing_phone']  = $fields['billing']['billing_phone']; 

    $fields2['shipping']['shipping_first_name'] = $fields['shipping']['shipping_first_name']; 
    $fields2['shipping']['shipping_last_name'] = $fields['shipping']['shipping_last_name']; 
    $fields2['shipping']['shipping_company'] = $fields['shipping']['shipping_company']; 
    $fields2['shipping']['shipping_address_1'] = $fields['shipping']['shipping_address_1']; 
    $fields2['shipping']['shipping_city'] = $fields['shipping']['shipping_city']; 
    $fields2['shipping']['shipping_postcode'] = $fields['shipping']['shipping_postcode']; 
    $fields2['shipping']['shipping_country'] = $fields['shipping']['shipping_country']; 

    // Add full width Classes and Clears to Adjustments  
    $fields2['billing']['billing_first_name'] = array(
     'label' => __('First Name', 'woocommerce'), 
    'class'  => array('form-row-wide'), 
    'clear'  => true, 
    'required' => true 
    ); 
    $fields2['billing']['billing_last_name'] = array(
    'label' => __('Last Name', 'woocommerce'), 
    'class'  => array('form-row-wide'), 
    'clear'  => true, 
     'required' => true 
    ); 
    $fields2['shipping']['shipping_first_name'] = array(
     'label' => __('First Name', 'woocommerce'), 
    'class'  => array('form-row-wide'), 
    'clear'  => true, 
    'required' => true 
    ); 
    $fields2['shipping']['shipping_last_name'] = array(
    'label' => __('Last Name', 'woocommerce'), 
    'class'  => array('form-row-wide'), 
    'clear'  => true, 
     'required' => true 
    ); 
    return $fields2; 
    } 

und dies funktioniert, aber bei der Aktivierung von Debug-Modus erhalte ich einen Fehler auf der chekcout Seite: Hinweis : Undefinierter Index: Auftrag in /html/wordpress/wp-content/plugins/woofcommerce/templates/checkout/form-shipping.php on line 58

Warnung: ungültiges Argument für foreach() in/html/wordpress/wp-content/plugins/woocommerce/templates/checkout/form-shipping.php on line 58

Kann aynone Sinn machen?

+0

Das erste, was ich sehe, ist, dass Sie haben einen zusätzlichen Raum zwischen [ ‚Abrechnung‘] und [ ‚billing_first_name‘]. Dies könnte die Ursache für Ihr Problem sein –

Antwort

3

Sie können unter dem folgenden Code versuchen, die Felder der Checkout-Seite neu anzuordnen. Sie können die Reihenfolge der Felder im Array ändern.

// for billing fields 

add_filter("woocommerce_checkout_fields", "new_order_fields"); 

function new_order_fields($fields) { 

    $order = array(
     "billing_company", 
     "billing_first_name", 
     "billing_last_name", 
     "billing_address_1", 
     "billing_address_2", 
     "billing_postcode", 
     "billing_country", 
     "billing_email", 
     "billing_phone" 
    ); 
    foreach($order as $field) { 
     $ordered_fields[$field] = $fields["billing"][$field]; 
    } 

    $fields["billing"] = $ordered_fields; 
    return $fields;  
} 

// for shipping fields 
add_filter("woocommerce_checkout_fields", "new_shiping_order_fields"); 

function new_shiping_order_fields($fields) { 

    $order = array( 
     "shipping_city", 
     "shipping_postcode", 
     "shipping_country",  
     "shipping_first_name", 
     "shipping_last_name", 
     "shipping_company", 
     "shipping_address_1", 
     "shipping_address_2" 

    ); 
    foreach($order as $field) { 
     $ordered_fields[$field] = $fields["shipping"][$field]; 
    } 

    $fields["shipping"] = $ordered_fields; 
    return $fields; 
} 
+0

Dies wird nur die Felder neu anordnen, aber ich muss auch das Feld für Bestellhinweise entfernen UND die volle Breite zu bestimmten Feldern hinzufügen (siehe in meinem Code oben) ... –

0

Sie können eine vollständige Anleitung darüber in the WooCommerce docs finden.

Sie definieren ein neues Array $fields2 und dieses Array verfügt nicht über alle erforderlichen Felder in woocommerce_checkout_fields. Sie müssen nur $fields["billing"] und $fields["shipping"] wie @pallavi showed you überschreiben.

Um ein Feld (ex. Order_comments) entfernen Sie diese Zeile

in Ihrer Funktion setzen können
unset($fields['order']['order_comments']);