WooCommerce - excelling eCommerce
Adding Drop Down menu to checkout (4 posts)

  1. mduran16
    Posted 2 years ago #

    Guys I'm stumped. I need to add a drop down menu to the checkout process and have it show the result in the invoice, however I'm struggling. I followed the guide on the woothemes site but I cant figure out how to adapt it to a drop down menu. Can anyone help me out?


  2. Mike Jolley
    Plugin Author

    Posted 2 years ago #

    If you google it, I think there is a plugin for adding custom checkout fields through a UI. Might be easier for you. I'm also developing one.

  3. mduran16
    Posted 2 years ago #

    Yeah, but im trying to find a way to do it without having to buy a $40 plugin. I only need to add one additional drop down box any ways, so I dont think its worth it honestly. I just want to know how to code it. I'll post what I have so far:

     * Add the field to the checkout**/
    add_action('woocommerce_after_order_notes', 'social_good_field');
    function social_good_field( $checkout ) {
        woocommerce_form_field( 'social good', array(
            'type'          => 'select',
            'class'         => array('my-field-class form-row-wide'),
            'label'         => __('Social Good'),
    		'clear' => false,
    		'options' => array(
    		'Good 1' => __( 'Montserrat', 'woocommerce' ),
    		'Good 2' => __( 'Morocco', 'woocommerce' ),
    		'Good 3' => __( 'Mozambique', 'woocommerce')
    		$checkout->get_value( 'social good' ));
     * Process the checkout**/
    add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
    function my_custom_checkout_field_process() {
        global $woocommerce;
        // Check if set, if its not set add an error.
        if (!$_POST['social good'])
             $woocommerce->add_error( __('Please select a social good.') );
     * Update the order meta with field value**/
    add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
    function my_custom_checkout_field_update_order_meta( $order_id ) {
        if ($_POST['social good']) update_post_meta( $order_id, 'Social Good', esc_attr($_POST['social good']));
  4. ABDpromotions
    Posted 2 years ago #

    I am looking to do the same thing. Were you able to solve this problem?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.