Created
February 27, 2019 07:15
-
-
Save Neshable/266abafe4c753051439b68d728edc760 to your computer and use it in GitHub Desktop.
WooCommerce Add Custom Fields to Order
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
| if ( ! function_exists('custom_meta_to_order') ) { | |
| add_action('woocommerce_checkout_update_order_meta', 'custom_meta_to_order', 20, 1); | |
| function custom_meta_to_order( $order_id ) { | |
| $order = wc_get_order( $order_id ); | |
| $order->update_meta_data( '_order_custom_field', 'value' ); | |
| $order->save(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment