Support » Plugins » Disable some mail notifications in Woocommerce

  • Resolved dat98cbr


    I can’t see why this code doesn’t work. I want to disable order status completed notifications for all cases except when there is a downloadable product. Help! 🙂

    [ Moderator note: code block fixed, please use the code button going forward. ]

    	add_action( 'woocommerce_email', 'unhook_some_emails' );
    	function unhook_some_emails( $email_class) {
    		global $woocommerce, $post;
    		$order = new WC_Order( $post->ID );
    		if (!$order->has_downloadable_item()) {
    			remove_action('woocommerce_order_status_completed_notification', array(&$email_class, 'customer_completed_order'));
Viewing 1 replies (of 1 total)
  • Right thought I could do it in one hook, but two are needed 🙂

    /** Hook for disabling sending emails during order complete, except downloadable products*/
    	add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
    	add_action('woocommerce_order_status_completed', 'send_download_notification');
    	function unhook_those_pesky_emails( $email_class) {
    	remove_action('woocommerce_order_status_completed_notification', array(&$email_class, 'customer_completed_order'));
    	function send_download_notification($order_id) {
      		global $woocommerce;
    		  $order = new WC_Order($order_id);
    		  if ($order->has_downloadable_item()){
    		  $mailer = $woocommerce->mailer();
    		  $mailer->customer_invoice( $order );
Viewing 1 replies (of 1 total)
  • The topic ‘Disable some mail notifications in Woocommerce’ is closed to new replies.