Skip to content

Instantly share code, notes, and snippets.

@ScottDeLuzio
Created August 14, 2015 23:20
Show Gist options
  • Save ScottDeLuzio/8cbdddad8b1436352e7a to your computer and use it in GitHub Desktop.
Save ScottDeLuzio/8cbdddad8b1436352e7a to your computer and use it in GitHub Desktop.
Update order meta with custom field value
<?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