What variables are available in notifications?

I'd like to customize the notification we receive when orders are placed.

How can I reference the email to use it in addition to SHIPPINGINFO

I see in helpers.php

$search_replace = array(
			'CUSTOMERNAME' => $customer_name,
			'ORDERID'      => $order->get_id(),
			'ORDERINFOSKU' => $order_info,
			'ORDERINFO'    => $order_info,
			'SHIPPINGINFO' => $shipping_billing_info,
			'PAYMENTINFO'  => $payment_info,
			'TOTAL'        => $order_total,
			'TRACKINGURL'  => $tracking_url,
			'ORDERNOTES'   => $order_notes,

I need CUSTOMEREMAIL

  • Allen
    • Design Lord, Child of Thor

    I was able to get this working by adding

    $customer_email = MP_EMAIL_USE_BILLIG_NAME ? $order->get_meta( 'mp_billing_info->email' )  : $order->get_meta( 'mp_shipping_info->email' );

    near line 261 and

    'CUSTOMEREMAIL'=> $customer_email,

    near line 277

  • James Morris
    • WordPress Enthusiast

    Hello Allen,

    I hope you are well today.

    Thank you for updating this thread with your findings. I'm glad you were able to find a solution to your problem. :slight_smile:

    I will pass on this thread to the developers so that they will be made aware of your suggestion and work around.

    Best regards,

    James Morris

  • James Morris
    • WordPress Enthusiast

    Hello Allen,

    Just a little quick update... I spoke with one of our Developers this evening and he said that you could accomplish what you're wanting to do with some code additions in your functions.php. This will enable you to have the functionality you want without the need to hack into plugin core files. That way, when your plugin updates, your changes won't be lost.

    Here's the code he provided:

    function wpmudev_custom_order_notification_body( $msg, $order ){
    
        $search_replace = array(
            'CUSTOMEREMAIL' => $order->get_meta( 'mp_billing_info->email' ),
            'SOMETHINGELSE' => 'This is something else I need to replace'
        );
    
        $msg = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $msg );
    
        return $msg;
    }
    
    //For Order message to customer
    add_filter( 'mp_order/notification_body', 'wpmudev_custom_order_notification_body', 20, 2 );
    //For order message to admin
    add_filter( 'mp_order_notification_admin_msg', 'wpmudev_custom_order_notification_body', 20, 2 );
    //For shipping message to customer
    add_filter( 'mp_order/shipment_notification_body', 'wpmudev_custom_order_notification_body', 20, 2 );

    I hope that helps! :slight_smile:

    Best regards,

    James Morris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.