magnificentjake
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom Email Triggering TwiceIt 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!
Forum: Fixing WordPress
In reply to: Custom Email Triggering TwiceI’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();orreturn 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.- This reply was modified 4 years, 3 months ago by magnificentjake.
Forum: Fixing WordPress
In reply to: Custom Email Triggering TwiceOk, 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?
Forum: Plugins
In reply to: [WooCommerce] WooCommerce Email Triggering TwiceOk, 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?
Forum: Fixing WordPress
In reply to: Custom Email Triggering TwiceSure 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.
Forum: Fixing WordPress
In reply to: Custom Email not Getting TemplateThat’s it working now, thanks so much for your help – I suspected it’d be something simple like that!
- This reply was modified 4 years, 3 months ago by magnificentjake.
Forum: Fixing WordPress
In reply to: Custom Email not Getting Templatepublic 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?
Forum: Fixing WordPress
In reply to: Custom Email not Getting Templatepublic 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’
- This reply was modified 4 years, 3 months ago by magnificentjake.