Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.11 KB | None | 0 0
  1. add_filter( 'woocommerce_checkout_fields' , 'monocommerce_reorder_checkout_billing_fields' );
  2. add_filter( 'woocommerce_checkout_fields' , 'monocommerce_reorder_checkout_shipping_fields' );
  3.  
  4. function monocommerce_reorder_checkout_billing_fields( $fields ) {
  5.  
  6.     // remove unwanted fields
  7.     unset($fields['order']['order_comments']);
  8.     unset($fields['billing']['billing_company']);
  9.     unset($fields['billing']['billing_phone']);
  10.  
  11.     // reset classes
  12.     $fields['billing']['billing_first_name']['class'] = array('');
  13.     $fields['billing']['billing_last_name']['class'] = array('');
  14.     $fields['billing']['billing_postcode']['class'] = array('');
  15.     $fields['billing']['billing_email']['class'] = array('');
  16.  
  17.     // set the placeholders
  18.     $fields['billing']['billing_first_name']['placeholder'] = 'First Name';
  19.     $fields['billing']['billing_last_name']['placeholder'] = 'Last Name';
  20.     $fields['billing']['billing_address_1']['placeholder'] = 'Address Line 1';
  21.     $fields['billing']['billing_address_2']['placeholder'] = 'Address Line 2';
  22.     $fields['billing']['billing_email']['placeholder'] = 'Email';
  23.     $fields['billing']['billing_postcode']['placeholder'] = 'Zipcode';
  24.  
  25.     // reorder everything
  26.     $order = array(
  27.         "billing_first_name",
  28.         "billing_last_name",
  29.         "billing_address_1",
  30.         "billing_address_2",
  31.         "billing_country",
  32.         "billing_city",
  33.         "billing_state",
  34.         "billing_postcode",
  35.         "billing_email"
  36.     );
  37.  
  38.     foreach($order as $field){
  39.         $fields["billing"][$field]['label'] = '';
  40.         $ordered_fields[$field] = $fields["billing"][$field];
  41.     }
  42.  
  43.     $fields["billing"] = $ordered_fields;
  44.  
  45.     return $fields;
  46. }
  47.  
  48. function monocommerce_reorder_checkout_shipping_fields( $fields ) {
  49.  
  50.     // remove unwanted fields
  51.     unset($fields['shipping']['shipping_company']);
  52.     unset($fields['shipping']['shipping_phone']);
  53.  
  54.     // reset classes
  55.     $fields['shipping']['shipping_first_name']['class'] = array('');
  56.     $fields['shipping']['shipping_last_name']['class'] = array('');
  57.     $fields['shipping']['shipping_postcode']['class'] = array('');
  58.     $fields['shipping']['shipping_email']['class'] = array('');
  59.  
  60.     // set the placeholders
  61.     $fields['shipping']['shipping_first_name']['placeholder'] = 'First Name';
  62.     $fields['shipping']['shipping_last_name']['placeholder'] = 'Last Name';
  63.     $fields['shipping']['shipping_address_1']['placeholder'] = 'Address Line 1';
  64.     $fields['shipping']['shipping_address_2']['placeholder'] = 'Address Line 2';
  65.     $fields['shipping']['shipping_email']['placeholder'] = 'Email';
  66.     $fields['shipping']['shipping_postcode']['placeholder'] = 'Zipcode';
  67.  
  68.     // reorder everything
  69.     $order = array(
  70.         "shipping_first_name",
  71.         "shipping_last_name",
  72.         "shipping_address_1",
  73.         "shipping_address_2",
  74.         "shipping_country",
  75.         "shipping_city",
  76.         "shipping_state",
  77.         "shipping_postcode",
  78.         "shipping_email"
  79.     );
  80.  
  81.     foreach($order as $field){
  82.         $fields["shipping"][$field]['label'] = '';
  83.         $ordered_fields[$field] = $fields["shipping"][$field];
  84.     }
  85.  
  86.     $fields["shipping"] = $ordered_fields;
  87.  
  88.     return $fields;
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement