Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Created December 8, 2022 08:12
Show Gist options
  • Save remcotolsma/db12cce947432dfa642a5234f838f512 to your computer and use it in GitHub Desktop.
Save remcotolsma/db12cce947432dfa642a5234f838f512 to your computer and use it in GitHub Desktop.
Combine WooCommerce order meta data in one meta data field.
<?php
add_action(
'woocommerce_after_order_object_save',
function( $order ) {
$data = [
$order->get_meta( 'meta 1' ),
$order->get_meta( 'meta 2' ),
$order->get_meta( 'meta 3' ),
$order->get_meta( 'meta 4' ),
];
$all = implode( ', ', $data );
$order->update_meta_data( 'meta all', $all );
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment