Disable Woocommerce E-mail for specific product
-
As the title suggests, I am looking to unhook an e-mail notification for a specific product. In this case I am trying to remove the ‘Order Status Completed’ e-mail, for product id ‘21962, 23325 and 23324′(one product in different languages).
I used parts of this code in other functions which worked fine, but when I try it here, all info out of Woocommerce orders disappears leaving me with attached image. When I put ‘$order->get_items();’ in comment the order overview reappears, though of course the function still doesn’t work. What am I doing wrong?
<?php function unhook_confirmed_email( $order, $email_class ) { $membershipID = array('21962', '23325', '23324'); //MULTILANG $items = $order->get_items(); $phtml = array(); foreach( $items as $item ) { $pid[] = $item['product_id']; } if(array_intersect($membershipID, $pid)){ // Remove completed order emails remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); } } ?>
- The topic ‘Disable Woocommerce E-mail for specific product’ is closed to new replies.