Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Add the field to the checkout*/
- add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
- function my_custom_checkout_field( $checkout ) {
- echo '<div id="my_custom_checkout_field" class="my_new_field"><h2>' . __('My Field') . '</h2>';
- woocommerce_form_field( 'my_field_name', array(
- 'type' => 'text',
- 'class' => array('my-field-class form-row-wide'),
- 'label' => __('Fill in this field'),
- 'placeholder' => __('Enter something'),
- ), $checkout->get_value( 'my_field_name' ));
- echo '</div>';
- }
- // Hook in
- add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
- // Our hooked in function - $fields is passed via the filter!
- function custom_override_checkout_fields( $fields ) {
- $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
- $fields['order']['order_comments']['label'] = 'My new label';
- return $fields;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement