Forked from woogists/wc-save-custom-checkout-field.php
Created
October 3, 2020 19:10
-
-
Save bobwol/51dfac63f9e08d543737c30df1a73657 to your computer and use it in GitHub Desktop.
[Customizing checkout fields using actions and filters] Save WooCommerce custom checkout field
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
| /** | |
| * 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 ( ! empty( $_POST['my_field_name'] ) ) { | |
| update_post_meta( $order_id, 'My Field', sanitize_text_field( $_POST['my_field_name'] ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment