• Resolved brijesh24

    (@brijesh24)


    Hello Support,

    I am looking to include the Stripe payment ID or transaction ID in the new order email that gets sent to the admin.

    This ID is available when clicking the little eye icon in order details.

    Is that possible to do?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @brijesh24

    Yes, you can include pretty much any data you want in the email. The transaction ID is stored by WooCommerce and is available by using the WC_Order::get_transaction_id() method. The order object is accessible within the email template so you can use that object to display the transaction ID.

    Kind Regards

    Thread Starter brijesh24

    (@brijesh24)

    Got it. I came up with the code below with help of Chat GPT and it works well. Thank you for the help.

    add_action('woocommerce_email_order_meta', 'add_transaction_id_to_admin_email', 20, 4);

    function add_transaction_id_to_admin_email($order, $sent_to_admin, $plain_text, $email) {
    // Check if the email is being sent to the admin
    if ($sent_to_admin && isset($email) && $email->id === 'new_order') {
    // Get the transaction ID from the order object
    $transaction_id = $order->get_transaction_id();

    // Only display the transaction ID if it exists
    if ($transaction_id) {
    if ($plain_text) {
    // For plain text emails
    echo "Transaction ID: " . $transaction_id . "\n";
    } else {
    // For HTML emails
    echo '<p><strong>Stripe Transaction ID:</strong> ' . esc_html($transaction_id) . '</p>';
    }
    }
    }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.