Last active
March 16, 2021 18:20
-
-
Save frankschrijvers/64e2ec709937fd7fe51cbde06887de2f to your computer and use it in GitHub Desktop.
Add a custom select field to the WooCommerce checkout page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //* Do NOT include the opening php tag shown above. Copy the code shown below. | |
| //* Add select field to the checkout page | |
| add_action('woocommerce_before_order_notes', 'wps_add_select_checkout_field'); | |
| function wps_add_select_checkout_field( $checkout ) { | |
| echo '<h2>'.__('Next Day Delivery').'</h2>'; | |
| woocommerce_form_field( 'daypart', array( | |
| 'type' => 'select', | |
| 'class' => array( 'wps-drop' ), | |
| 'label' => __( 'Delivery options' ), | |
| 'options' => array( | |
| 'blank' => __( 'Select a day part', 'wps' ), | |
| 'morning' => __( 'In the morning', 'wps' ), | |
| 'afternoon' => __( 'In the afternoon', 'wps' ), | |
| 'evening' => __( 'In the evening', 'wps' ) | |
| ) | |
| ), | |
| $checkout->get_value( 'daypart' )); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment