Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created June 17, 2019 19:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/286ff75c5f85852c774686dd016fd96b to your computer and use it in GitHub Desktop.
Save plugin-republic/286ff75c5f85852c774686dd016fd96b to your computer and use it in GitHub Desktop.
<?php
/**
* Display custom item data in the cart
*/
function plugin_republic_get_item_data( $item_data, $cart_item_data ) {
if( isset( $cart_item_data['pr_field'] ) ) {
$item_data[] = array(
'key' => __( 'Your name', 'plugin-republic' ),
'value' => wc_clean( $cart_item_data['pr_field'] )
);
}
return $item_data;
}
add_filter( 'woocommerce_get_item_data', 'plugin_republic_get_item_data', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment