• I am using “woocommerce_email_classes” filter to register custom emails. However, I came into an issue, where emails are disabled with the setting enabled. Matter of fact, all admin emails are disabled or return a fatal error. I don’t think this is an expected effect, at least for me, since emails are tied to order status, and kinda a hand-in-hand thing.

    I am using wordpress 5.1.0

    Is there a way to keep email functionality, but still have all the rest of the stuff disabled?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor ospiotr

    (@ospiotr)

    Hi @ghostpengy

    Thank you for taking your time to post.

    Please paste your PHP code that you are using for custom emails.
    I will look into this and check if it is possible to achieve this scenario.

    Thread Starter Ghostpengy

    (@ghostpengy)

    Sure, see code below. It all seems to work till filter hook “woocommerce_email_classes”, which fires when disable Admin is unchecked, but not when enabled.

    /**
     * Class Custom_WC_Email
     */
    class Custom_WC_Email {
    
    	/**
    	 * Custom_WC_Email constructor.
    	 */
    	public function __construct() {
        // Filtering the emails and adding our own email.
    		add_filter( 'woocommerce_email_classes', array( $this, 'register_email' ), 90, 1 );
        // Absolute path to the plugin folder.
    		//define( 'CUSTOM_WC_EMAIL_PATH', plugin_dir_path( __FILE__ ) );
    	}
    
    	/**
    	 * @param array $emails
    	 *
    	 * @return array
    	 */
    	public function register_email( $emails ) {
    		require_once 'emails/class-wc-customer-shipping-email.php';
    		require_once 'emails/class-wc-customer-missing-payment-email.php';
    		require_once 'emails/class-wc-customer-payment-received-email.php';
    		require_once 'emails/class-wc-customer-cancelled-email.php';
    
    		$emails['wc_customer_shipping_email'] = new WC_Customer_Shipping_Email();
    		$emails['wc_customer_missing_payment_email'] = new WC_Customer_Missing_Payment_Email();
    		$emails['wc_customer_payment_received_email'] = new WC_Customer_Payment_Received_Email();
    		$emails['wc_customer_cancelled_email'] = new WC_Customer_Cancelled_Email();
    
    		return $emails;
    		
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable WooCommerce Admin disables email filter’ is closed to new replies.