Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /* Add the field to the checkout*/
  2.  
  3. add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
  4.  
  5. function my_custom_checkout_field( $checkout ) {
  6.  
  7. echo '<div id="my_custom_checkout_field" class="my_new_field"><h2>' . __('My Field') . '</h2>';
  8.  
  9. woocommerce_form_field( 'my_field_name', array(
  10. 'type' => 'text',
  11. 'class' => array('my-field-class form-row-wide'),
  12. 'label' => __('Fill in this field'),
  13. 'placeholder' => __('Enter something'),
  14. ), $checkout->get_value( 'my_field_name' ));
  15.  
  16. echo '</div>';
  17. }
  18.  
  19. // Hook in
  20. add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  21.  
  22. // Our hooked in function - $fields is passed via the filter!
  23.  
  24. function custom_override_checkout_fields( $fields ) {
  25.  
  26. $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
  27.  
  28. $fields['order']['order_comments']['label'] = 'My new label';
  29. return $fields;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement