Skip to content

Instantly share code, notes, and snippets.

@bhavik-kiri
Created November 4, 2017 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavik-kiri/3ea6247fb4c707f0a6610335ed6c64a0 to your computer and use it in GitHub Desktop.
Save bhavik-kiri/3ea6247fb4c707f0a6610335ed6c64a0 to your computer and use it in GitHub Desktop.
<?php
/**
* Add order item meta.
*/
add_action( 'woocommerce_add_order_item_meta', 'add_order_item_meta' , 10, 2);
function add_order_item_meta ( $item_id, $values ) {
if ( isset( $values [ 'custom_data' ] ) ) {
$custom_data = $values [ 'custom_data' ];
wc_add_order_item_meta( $item_id, 'Name', $custom_data['customer_name'] );
wc_add_order_item_meta( $item_id, 'Message', $custom_data['customer_message'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment