I must to edit a product name in woocommerce when in the product was add ('_aggiunte), _aggiunte is a custom field of woocommerce_order_itemmeta tabs.
I try with this code but don't word.
function woocommerce_new_order_item_add_aggiunte($item_id, $item, $order_id) {
$item_type = $item->get_type();
$order= wc_get_order($order_id);
// We only want product order type
if ($item_type == 'line_item') {
$product = wc_get_product($item->get_product_id());
$new_name=get_post_meta($product_id, '_tmcartepo_data', true);
$item->set_name($new_name);
$item->save();
}
}
thanks. I want to show produtname-aggiunte.