Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sandeepwisetr/a1b2102df365f80fe132aa2e3f035c44 to your computer and use it in GitHub Desktop.
Save sandeepwisetr/a1b2102df365f80fe132aa2e3f035c44 to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_checkout_update_order_meta', function ( $order_id, $data ) {
if ( ! isset( $_POST['_wfacp_post_id'] ) ) {
return;
}
$order = wc_get_order( $order_id );
$field = [
'shipping_number',
'shipping_neighborhood',
'billing_persontype',
'billing_cpf',
'billing_rg',
'billing_cpf',
'billing_cnpj',
'billing_ie',
'billing_cnpj',
'birthdate_sex',
'billing_number',
'billing_neighborhood',
'billing_cellphone'
];
foreach ( $field as $item ) {
if ( isset( $_POST[ $item ] ) ) {
$order->{$item} = $_POST[ $item ];
update_post_meta( $order->get_id(), "_" . $item, $_POST[ $item ] );
}
}
$order->save();
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment