Skip to content

Instantly share code, notes, and snippets.

@bhavik-kiri
Last active November 11, 2017 11:20
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/56683f3874a5ae56e3c194e849d3651e to your computer and use it in GitHub Desktop.
Save bhavik-kiri/56683f3874a5ae56e3c194e849d3651e to your computer and use it in GitHub Desktop.
<?php
/**
* Display custom data on cart and checkout page.
*/
add_filter( 'woocommerce_get_item_data', 'get_item_data' , 25, 2 );
function get_item_data ( $other_data, $cart_item ) {
if ( isset( $cart_item [ 'custom_data' ] ) ) {
$custom_data = $cart_item [ 'custom_data' ];
$other_data[] = array( 'name' => 'Name',
'display' => $custom_data['customer_name'] );
$other_data[] = array( 'name' => 'Message',
'display' => $custom_data['customer_message'] );
}
return $other_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment