custom trigger

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #130259
    september18.nl
    Participant

    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.

    #130519
    Moshtafizur
    Moderator
    Plugin Support

    Hi there,

    I have escalated this with our development team. They will let you know if it would be possible.

    Kind regards.

    #130593
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    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.

    #130894
    september18.nl
    Participant

    where should i add the snippet, just in theme functions file?

    #130895
    september18.nl
    Participant

    is 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

    #131194
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    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 );
    #133973
    Tom Anbinder
    Moderator
    Plugin Support

    Update: 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”).

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.