• Resolved imartingo

    (@imartingo)


    Hello there!

    I have found that the refund status change sends an email to the same email that are written on Cancelled order, New order and Failed Order.

    But there isn’t a template for that.

    I have installed a plugin that has this piece of code so that the customer can receive the same failed and canceled email:

    
    function send_email_to_customer_on_cancelled_order_in_woocommerce() {
        load_plugin_textdomain( 'send-email-to-customer-on-cancelled-order-in-woocommerce', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
    }
    add_action( 'plugins_loaded', 'send_email_to_customer_on_cancelled_order_in_woocommerce' );
    
    add_action('woocommerce_order_status_changed', 'seccow_send_email', 10, 4 );
    function seccow_send_email( $order_id, $old_status, $new_status, $order ){
        if ( $new_status == 'cancelled' || $new_status == 'failed' ){
            $wc_emails = WC()->mailer()->get_emails(); // Obtener todas las instancias de WC_emails
            $email_cliente = $order->get_billing_email(); // Email del cliente
        }
    
        if ( $new_status == 'cancelled' ) {
            // Cambiar el destinatario de la instancia
            $wc_emails['WC_Email_Cancelled_Order']->recipient .= ',' . $email_cliente;
            // Enviar email desde la instancia
            $wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id );
        } 
        elseif ( $new_status == 'failed' ) {
            // Cambiar el destinatario de la instancia
            $wc_emails['WC_Email_Failed_Order']->recipient .= ',' . $email_cliente;
            // Enviar email desde la instancia
            $wc_emails['WC_Email_Failed_Order']->trigger( $order_id );
        } 
    }

    However there is nothing here that listens to the refund status change.

    Is there something I’m missing?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is it possible you have another code snippet somewhere that’s sending refund emails to the same address specified on Cancelled/New/Failed Order? I might be wrong, but I don’t remember that being built-in Woo functionality.

    If the question is more about the customer’s refund email, the templates for that are in /emails/customer-refunded-order.php and /emails/plain/customer-refunded-order.php. You’ll see that one listening for refunds in class-wc-email-customer-refunded-order.php.

    Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    @imartingo

    WooCommerce does have the option to send your customer an email after you’ve refunded their order. You can check whether that is enabled via WooCommerce > Settings > Emails > Refunded Order. The email uses this template: woocommerce/templates/emails/customer-refunded-order.php

    If you have a plugin that’s also sending these emails, perhaps this is why there are 2 going out?

    I would try disabling that plugin and then running a test order and refund to see if it resolves the issue.

    Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please feel free to start a new thread.

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

The topic ‘Refund admin email’ is closed to new replies.