Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter magnificentjake

    (@magnificentjake)

    It turns out I had another return clause in my functions file where I was doing the inclusion statement. All fixed now – thanks for the help!

    Thread Starter magnificentjake

    (@magnificentjake)

    I’d been basing a lot of my class file on the files in woocommerce/includes/emails , most (all?) of which have a return new WC_Email_Customer_Completed_Order(); or return new WC_Email_New_Order(); (and so forth) line right at the end of the file. Omitting my equivalent of that line nipped the double email in the bud, but I’m just worried something elsewhere might break without it.

    Thread Starter magnificentjake

    (@magnificentjake)

    Ok, so I actually managed to fix it myself, but I’m not sure if my fix is problematic? Removing the return new Foundry_Code_Email(); clause at the end of the php file appears to have sorted it, but I notice that all the WooCommerce core templates have a return clause at the end.

    Is this going to cause problems?

    Thread Starter magnificentjake

    (@magnificentjake)

    Ok, so I actually managed to fix it myself, but I’m not sure if my fix is problematic? Removing the return new Foundry_Code_Email(); clause at the end of the php file appears to have sorted it, but I notice that all the WooCommerce core templates have a return clause at the end.

    Is this going to cause problems?

    Thread Starter magnificentjake

    (@magnificentjake)

    Sure thing, thanks very much for pointing me in that direction; I’m trying to test that approach at the moment.

    Am I right in saying I need to add this somewhere in the trigger function then?

    remove_action( 'woocommerce_order_status_completed_notification', 'trigger', 10 );

    If I’m right in that approach (probably unlikely!) it doesn’t appear to have fixed the issue unfortunately so perhaps some more sleuthing required.

    Thread Starter magnificentjake

    (@magnificentjake)

    That’s it working now, thanks so much for your help – I suspected it’d be something simple like that!

    Thread Starter magnificentjake

    (@magnificentjake)

    public function get_content_html() {
    		return wc_get_template_html(
    				$this->template_html,
    				array(
    					'order'              => $this->object,
    					'email_heading'      => $this->get_heading(),
    					'additional_content' => $this->get_additional_content(),
    					'sent_to_admin'      => false,
    					'plain_text'         => false,
    					'email'              => $this,
    				)
    			);
    	}
    
    	public function get_content_plain() {
    		return wc_get_template_html(
    				$this->template_plain,
    				array(
    					'order'              => $this->object,
    					'email_heading'      => $this->get_heading(),
    					'additional_content' => $this->get_additional_content(),
    					'sent_to_admin'      => false,
    					'plain_text'         => true,
    					'email'              => $this,
    				)
    			);
    	

    These are my get_content_html() and get_content_plain() functions, based on the existing WC email examples. Do I need to add template_base in here somewhere?

    Thread Starter magnificentjake

    (@magnificentjake)

    public function __construct() {
    		
    		// Unique ID for custom email
    		$this->id = 'foundry_code_email';
    
    		// Is a customer email
    		$this->customer_email = true;
    
    		// Title field in WooCommerce Email settings
    		$this->title = __( 'Foundry Premium Content Email', 'woocommerce' );
    
    		// Description field in WooCommerce email settings
    		$this->description = __( 'Foundry email is sent when customer purchases Foundry Premium Content', 'woocommerce' );
    
    		
    				$this->template_base	= WP_PLUGIN_DIR . '/foundry-premium-content/templates/';
    		$this->template_html = 'emails/foundry-code-email.php';
    		$this->template_plain = 'emails/plain/foundry-code-email.php';
    		// $this->template_html = 'customer-reset-password.php';
    
    		$this->placeholders = array(
    			// '{site_title}'	=> $this->get_blogname(),
    			'{order_date}'	=> '',
    			'{order_number}' => '',
    		);
    
    		// Trigger email when payment is complete
    		add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 );
    		
    
    		// Call parent constructor to load any other defaults not explicitly defined here.
    		parent::__construct();
    	}

    That’s my __construct() function for my custom email class. The plugin itself is called ‘foundry-premium-content’, and the email template in question’s path is ‘foundry-premium-content/templates/emails/foundry-code-email.php’

Viewing 8 replies - 1 through 8 (of 8 total)