Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a custom select field to the WooCommerce checkout page
//* 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