Created
July 7, 2015 22:07
-
-
Save BurlesonBrad/5bf14dfad195ca5df9a6 to your computer and use it in GitHub Desktop.
For Manja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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