custom trigger addres change

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

    We want to sent an email when a user changes his address

    i know i should use a custom trigger, what is the best practice to add this trigger to functions.php

    #136279
    Moshtafizur
    Moderator
    Plugin Support

    Hi there,

    Thanks for reaching out.

    I have escalated this with our development team. They will back to you as soon as possible.

    Kind regards.

    #136398
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    I think what you need is the woocommerce_after_save_address_validation trigger:

    1. add it to the “Custom triggers” option (in “WooCommerce > Settings > Custom Emails > General”),
    2. select it in your custom email’s “Triggers” option (in “WooCommerce > Settings > Emails > Custom email #X”).

    P.S. If you want to use the [user_prop] shortcode in the custom email’s “Email content” option – add this PHP snippet to your site:

    add_filter( 'alg_wc_custom_emails_is_user_email', function ( $is_user_email, $current_filter ) {
        return ( 'woocommerce_after_save_address_validation_notification' === $current_filter ? true : $is_user_email );
    }, 10, 2 );

    And then you can use this in your email’s content:

    [user_prop key="nickname"]
    [user_prop key="description"]
    [user_prop key="first_name"]
    [user_prop key="last_name"]
    [user_prop key="user_login"]
    [user_prop key="user_nicename"]
    [user_prop key="user_email"]
    [user_prop key="user_url"]
    [user_prop key="display_name"]

    Please give it a try and let me know what you think.

    #136681
    Tom Anbinder
    Moderator
    Plugin Support

    Update: Since the latest plugin v2.9.3, we can now achieve what we need without custom triggers and code. There are two new “Extra” triggers: “Customer address saved” and “Customer address changed”. The first one is the same as the woocommerce_after_save_address_validation custom trigger I mentioned earlier. The second one is fired only if the address was actually changed (i.e., not just saved without any changes).

    Please give it a try and let me know what you think.

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