Take a look at the WooCommerce docs here: Tutorial – Customising checkout fields using actions and filters
your code would look something like this:
function my_custom_checkout_field( $checkout ) {
woocommerce_form_field( 'my_field_name', array(
'type' => 'select',
'class' => array('my-field-class form-row-wide'),
'label' => __('Question?'),
'placeholder' => __('Enter something'),
'options' => array(
'Yes' => __('Yes', 'woocommerce' ),
'No' => __('No', 'woocommerce' )
)
), $checkout->get_value( 'my_field_name' ));
}
though the input also needs processing to be displayed in the WC admin. If you have little experience with PHP, it’s not that easy though. You could take a look at this plugin for inspiration.
Related Posts:
- Adding option values as an array using a multi selectable select box
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- Load google font script based on optgroup label selected
- Contact form 7 select box different value-text than content-text in option [closed]
- Autogenerate wordpress shortcodes using array?
- Tag selector like stackexchange?
- Building a scalable WordPress favouriting plugin – one serialised meta value array or many meta records
- How can I show drafts in wp_dropdown_pages list?
- How to fetch serialized data from wordpress options
- Customize the Sorting Dropdown in WooCommerce
- Woocommerce: Changing the variations select default value? [closed]
- merging an array to an existing array using add_filter
- WP Job Manager Category Drop-down; Change Placeholder Text Via Filter
- Pass a php string to a javascript variable
- Easiest way to add dropdown to a page
- How to output CMB2 select options from repeated groups select elements?
- I want to auto populate data in three fields if one drop down is selected
- Using Wishlist Member and I need to access a user’s status
- Redirect to another page using contact form 7? [closed]
- Any idea how to get something like this to work? [closed]
- What form should the $query media query array have for an Elementor page builder function? [closed]
- Integer in Array returns null
- Add to array, redirect and display
- Add key and value to an array in another file
- Add a “default sorting” menu to child store pages
- Select Form Element Not Saving from Plugin Options
- Contact Form 7 “non-selectable” options in a drop down [closed]
- Dropdown menu on click change
- Editable select options in quick edit OR in plugin settings
- Creating an array from form inputs before it is posted to the options database
- Adding an item to an anonymous array inside a filter?
- $wpdb not working wordpress plugin ajax call
- How to make this custom capability work? [duplicate]
- Plugin error “array_key_exists(): The first argument should be either a string or an integer” [closed]
- How to Display image from Menu Image in Walker Dropdown Select Menu
- show-hide based on select option jquery wordpress
- Need help getting a certain value out of a multi dimensional array
- Adding icons next to categories in wp_nav_menu
- Page doesn’t load
- Adding an onchange event to a custom dropdown menu in WordPress
- wordpress option page data from select form is not saving to database
- Pull Data from DB for Admin Page Display as Relates to Admin Page Class by BA Internet
- Insert dynamic content into posts
- Plugin use of ajax/jquery depending dropdown
- how to search through plugin in wordpress cimy-user-extra-fields?
- how to show selected options drop down menu values in attributes field in after saving post.php
- Custom wordpress plugin does not save select element
- Automatically install wordpress plugin at theme activation
- How to run Two WordPress blogs with different themes and with single database and same content
- How to show custom message once on plugin activation?
- How to notify users of blog updates a la Admin Plugin Update notifications?
- plugin shortcodes not working on custom theme- unsure how to fix
- PDF download – use wordpress functions
- API to filter new user registration $POST data?
- Set cookie then immediantly refresh the page
- How to remove duplicate Custom Fields?
- Calling a plugin in theme development
- How can I disable the multisite feature of WordPress 3.0?
- How to translate __(”) strings in admin [closed]
- trying to get user info in plugin
- Customize permalink wordpress category id
- Take input from form and pass it to function using a wp-plugin
- Translation for the plugin using redux framework does not work
- Re use the list table for a custom post type on another page
- Hook into existing tinyMCE button
- How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
- How can I apply a WP filter on specific plugin version
- How to create Admin Notice from Plugin with argument? [duplicate]
- Can I do in-page changes binding events/triggers to actions in WordPress?
- Can inactive WordPress plugins still load scripts?
- Change the number of plugins counted on wp-admin/plugins.php
- Changing the Organize Series Listing Pages
- Way to send multiple values for column to MySQL?
- What’s the right way to implement functions in footer.php
- how to set parent forum link to menu page?
- Notify bar plugin not showing up
- Our plugin tags not appearing in WordPress Plugin Repository
- How to get saved elementor template list programmatically?
- Conditional delete metadata does not works
- “Disable” specific plugins on certain pages
- The function called on the wp head hook becomes null
- custom post type get_posts() function not work
- How to add defer to WordPress Plugin javascript? [duplicate]
- Powerpress upload a podcast without creating a post for it
- Remove metatag from a particular page
- How to disable/enable a plugin at a specific time
- user specific private content
- Enable plugins that are “not supported”
- Need Help Understanding Debug Log Errors
- custom/automatic export function – one post at a time?
- How to create multi-slug admin page and retrieve it with $_GET or something?
- Site not displaying correctly when re-directing from root to sub-directory
- How to structure plugin in to functions?
- Breadcrumb is not generating the correct post page url
- Check if post was modified by editor different than post author
- Award points if a specific custom taxonomy is selected – Cubepoints
- SOLVED – $wp_admin_bar and AJAX calls
- How to change prices per number ordered in WooCommerce [closed]
- How to add an active state class to my info box
- Using ACF to allow user to add and edit multiple saved forms