Top WooCommerce & WordPress Plugins › Forums › Custom Emails for WooCommerce › custom trigger
- Support forum for the Additional Custom Emails for WooCommerce.
Tagged: Custom triggers
- This topic has 6 replies, 3 voices, and was last updated 3 months ago by Tom Anbinder.
-
AuthorPosts
-
December 11, 2023 at 9:15 am #130259september18.nlParticipant
We want to sent an email when a user puts the subscription on hold.
If we use the default subscription status is updated to on hold in woocommerce it is also sending the email when woocommerce is renewing the subscription with sepa incasso.
Because woocommerce changes status to Waiting and then reactivate with the message: Updated subscription from ‘on hold’ to ‘Active’ until the payment fails, because processing a SEPA Direct Debit payment requires some time.
so i only want to send an email if a user is more than a specific time(1 hour) on the status on hold.
i see you have a custom trigger option but can’t find Documentation how it works or an example how to do it.
December 14, 2023 at 8:07 pm #130519Hi there,
I have escalated this with our development team. They will let you know if it would be possible.
Kind regards.
December 15, 2023 at 4:12 pm #130593Hi,
Please try this:
Select “Subscriptions: Subscription status updated to” in “Enabled triggers groups” in “WooCommerce > Settings > Custom Emails > General > Advanced Options”.
Then go to “WooCommerce > Settings > Emails > Custom email”, set “Triggers” to “Subscription status updated to On Hold”, and “Delay” to “1 hour”.
Now, to ensure that the email is sent only if the subscription is still “on hold”, we need to add this snippet:
add_filter( 'alg_wc_custom_emails_do_send_order_email', function ( $do_send, $email, $order ) { return $order->has_status( 'on-hold' ); }, 10, 3 );
Please give it a try and let me know what you think.
December 19, 2023 at 8:17 am #130894september18.nlParticipantwhere should i add the snippet, just in theme functions file?
December 19, 2023 at 8:34 am #130895september18.nlParticipantis the filter function applied to every mail thats using “Subscription status updated to On Hold” or every “Subscription status updated to”.
is it posible to also connect the filter to one specific mail? so apply only the filter to alg_wc_custom_email_4 and not to 3,2 and 1
December 21, 2023 at 3:01 pm #131194Hi,
where should i add the snippet, just in theme functions file?
Yes, you can put it in your child theme’s
functions.php
file.is it posible to also connect the filter to one specific mail?
Yes, you can use the
$email->alg_wc_ce_id
property, like this:add_filter( 'alg_wc_custom_emails_do_send_order_email', function ( $do_send, $email, $order ) { if ( 1 == $email->alg_wc_ce_id ) { // for the "Custom email #1" return $order->has_status( 'on-hold' ); } return $do_send; }, 10, 3 );
January 29, 2024 at 9:40 pm #133973Update: Since the plugin v2.8.0, it’s now possible to achieve the same without the snippet – with the new “Require order status” (and “Exclude order status”) option (in “WooCommerce > Settings > Emails > Custom email #X > Order Options”).
-
AuthorPosts
- You must be logged in to reply to this topic.