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
- How to make a drop-down list so you can press and change display like on this website by using wordpress or CSS
- Activate plugins by a theme’s functions.php?
- Unable to show 4 products in a row
- Adding hero images to blog posts
- How wordpress plugin hooks works? [duplicate]
- How to create plugin list groups?
- How to add a filter conditionally based on page related Conditional Tags
- Notify new post on page
- How to load css files in a specific order
- Custom Post Type – Permalink Problem
- Allow a role to edit one specific plugin
- Show latest and related articles from 3 different blogs
- Replace all media (images)
- Post curl function save twice using plugin hook function wordpress
- wordpress plugin JSON API search within specific category
- 404 not found problem with URL rewrite custom category
- Woocommerce custom fields
- This plugin throws error on the events page only [closed]
- Wysija Newsletters: Redirect After Subcription
- Frontpage Admin Bar Disappeared
- making users able to add their own products wp e-commerce [closed]
- Getting Post Permalink Outside of Loop Not Working
- Selling Downloadable Products [closed]
- Trying to use Advanced Custom Fields with custom image sizes
- ACF: Hide a div or template section when a custom field (in a field group) is empty
- Gutenberg: Dynamic Block – Show saved data in the editor
- Is it possible to send user new password after they clicking on forgot password in word press
- wordpress last all added get meta value by post id
- Register additional wp plugin directory
- Adding Category in URL in some post
- How to prevent page load on form submission
- Trying to Understand Shortcodes.
- How to get the real address from a url (permalink)
- Is a custom post type considred a plugin?
- How to delete remain data in WP database after deleting custom post via admin interface
- How to link that “logged in” in “you must be logged in to post a comment” with custom login page on WordPress?
- Get value of a key from a Plugin Serialized array
- 404 Page when emptying spam or deleting a plugin
- File permissions for wp-minify plugin
- Migrate DB Plugin: Error “The directory needs to be writable”
- Is there a way to combine categories and their hierarchy into the admin listing page?
- Automatically set posts to NoIndex depending on category?
- Get post id in Post Page within Wp-admin
- Custom time field won’t sort regardless of format
- How to fix ‘Call to undefined function do_settings()’ error?
- __FILE__ in WordPress plugins
- Move specific javascript to the footer
- How to send email when my plugin is activated?
- Simple WordPress function / plugin to redirect a site
- Integrate Mailchimp to a Contact Form 7 contact form [closed]
- Plugins to generate CSS Sprites? [closed]
- Enqueue scripts in the footer
- Sort Reviews/Ratings by date on Woocommerce