Skip to content

Instantly share code, notes, and snippets.

@BurlesonBrad
Created July 7, 2015 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BurlesonBrad/5bf14dfad195ca5df9a6 to your computer and use it in GitHub Desktop.
Save BurlesonBrad/5bf14dfad195ca5df9a6 to your computer and use it in GitHub Desktop.
For Manja
// Our hooked in function - $fields is passed via the filter!
function dropdown( $fields ) {
$fields['billing']['dropdown'] = array(
'label' => __('Howdy Manja. Would You Like Your Order Gift Wrapped for Free?', 'woocommerce'),
'placeholder' => _x('dropdown', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
'clear' => true,
'type' => 'select',
'options' => array(
'option 1' => __('YUP', 'woocommerce' ),
'option 2' => __('NOPE', 'woocommerce' )
)//end of options
);
return $fields;
}
/** * Update the order meta with field value */
add_action( 'woocommerce_checkout_update_order_meta', 'dropdown' );
function dropdown_update_order_meta( $order_id ) {
if ( ! empty( $_POST['dropdown'] ) )
{ update_post_meta( $order_id, 'Wrapped?', sanitize_text_field( $_POST['dropdown'] ) ); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment