Reply to Buyer in the Gift Card Email

When a customer receives a gift card email, the “Reply-to” for the email will be your store’s configured email address by default. If you instead want the recipient customer to reply to the purchasing customer, you can set the Billing Email, First Name, and Last Name in the “Reply-to” field for the gift card emails.

Note: If you are more comfortable adding the code to your functions.php you can do that instead of using Code Snippets.

1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a new Snippet with the following code:

add_filter( 'woocommerce_email_headers', 'pwgc_reply_to_buyer', 1, 4 );
function pwgc_reply_to_buyer( $header, $email_id, $gift_card, $email ) {
    // Only for "PW Gift Card" email notification
    if ('pwgc_email' !== $email_id ) {
        return $header;
    }

    $order = is_a( $gift_card, 'PW_Gift_Card_Item_Data' ) ? $gift_card->order : false;
    if ( is_a( $order, 'WC_Order' ) ) {
        $reply_to_name  = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
        $reply_to_email = $order->get_billing_email();

        $header  = 'Content-Type: ' . $email->get_content_type() . "\r\n";
        $header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n";
    }

    return $header;
}
Skip to content