Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // show the custom meta data on the cart and checkout pages
- add_filter( 'woocommerce_get_item_data', 'tp_get_custom_item_data', 10, 2 );
- function tp_get_custom_item_data( $item_data, $cart_item ) {
- if( isset( $cart_item['size'] ) ) {
- $item_data[] = array( 'name' => 'Size', 'value' => $cart_item['size'] );
- }
- return $item_data;
- }
- // add custom meta to order
- // nb action 'woocommerce_add_order_item_meta' is deprecated
- add_action( 'woocommerce_new_order_item', 'tp_add_custom_meta_to_order', 99, 3 );
- function tp_add_custom_meta_to_order( $item_id, $item, $order_id ) {
- if( isset( $item->legacy_values['size'] ) ) {
- wc_add_order_item_meta( $item_id, 'Size', $item->legacy_values['size'] );
- }
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement