Created
August 14, 2015 23:20
-
-
Save ScottDeLuzio/8cbdddad8b1436352e7a to your computer and use it in GitHub Desktop.
Update order meta with custom field value
This file contains 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
<?php | |
/** | |
* Update the order meta with field value | |
*/ | |
add_action( 'woocommerce_checkout_update_order_meta', 'some_custom_checkout_field_update_order_meta' ); | |
function some_custom_checkout_field_update_order_meta( $order_id ) { | |
if ( ! empty( $_POST['some_field_name'] ) ) { | |
update_post_meta( $order_id, 'Some Field', sanitize_text_field( $_POST['some_field_name'] ) ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment