I use this code for get meta in some product.
$meta_data = $item->get_formatted_meta_data($hideprefix = '_', $include_all = false );
foreach ($meta_data as $dato){
$datoo = (array) $dato;
$mess .= $datoo['display_key'].': ' .$datoo['value']. '<br>' ;
}
one of these key is "Nome File".
Now i need to send a mail when this meta is empty in all the products.
I need to modify this code but i don't know how...
// On order completed status
add_action('woocommerce_order_status_processing', 'send_a_custom_email', 20, 1 );
//add_action('woocommerce_order_status_on-hold', 'send_a_custom_email', 20, 1 );
function send_a_custom_email( $order_id ) {
$order = wc_get_order( $order_id ); // The WC_Order object
foreach ( $order->get_items() as $item_id => $item ) {
$product = $item->get_product(); // The WC_Product object
// Get the parent product ID for product variations for product categories
$the_id = $product->is_type('variation') ? $product->get_parent_id() : $product->get_id();
if ( has_term( array(115, 117, 555, 556, 789, 786, 554), 'product_cat', $the_id ) ) {
can someone help me?