简体   繁体   English

在Woocommerce中将订单交易ID添加到管理员新订单电子邮件通知中

[英]Add orders transaction id to admin new order email notification in Woocommerce

I am trying to find a way to add the Authorize.net ID (not the woocommerce customer ID) to the admin order template. 我正在尝试找到一种将Authorize.net ID(而不是woocommerce客户ID)添加到管理订单模板的方法。 The Authorize.net ID shows on the order screen: Authorize.net ID在订单屏幕上显示:

请参阅订单屏幕截图。

I want that ID # to go in the email. 我希望该ID#出现在电子邮件中。 Here is the e-mail template: 这是电子邮件模板:

<?php
/**
 * Admin new order email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-new-order.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @author WooThemes
 * @package WooCommerce/Templates/Emails/HTML
 * @version 2.5.0
 */

 if ( ! defined( 'ABSPATH' ) ) {
    exit;
 }

 /**
  * @hooked WC_Emails::email_header() Output the email header
  */
 do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

 <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>


 <?php

 /**
  * @hooked WC_Emails::order_details() Shows the order details table.
  * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
  * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
  * @since 2.5.0
  */

do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

 /**
  * @hooked WC_Emails::order_meta() Shows order meta data.
  */
 do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email, $transaction_ID );

 /**
  * @hooked WC_Emails::customer_details() Shows customer details
  * @hooked WC_Emails::email_address() Shows email address
  */
 do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );



 /**
  * @hooked WC_Emails::email_footer() Output the email footer
  */
 do_action( 'woocommerce_email_footer', $email );

Any ideas? 有任何想法吗? I appreciate any guidance I can get. 感谢您能获得的任何指导。

This code will display the transaction ID (when it exists) in Woocommerce admin email notifications: 此代码将在Woocommerce管理员电子邮件通知中显示交易ID (如果存在)

// Display the payment gateway transwaction ID on email notifications
add_action('woocommerce_email_order_details', 'before_email_order_details_transaction_id', 5, 4 );
function before_email_order_details_transaction_id( $order, $sent_to_admin, $plain_text, $email ) {

    if( $order->get_transaction_id() && $sent_to_admin )
        echo '<p><strong>' . __("Transaction id") . ': </strong>' . $order->get_transaction_id() . '<p>';
}

Code goes in function.php file of your active child theme (or active theme). 代码进入您的活动子主题(或活动主题)的function.php文件中。 Tested and works. 经过测试和工作。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Woocommerce 向管理员发送“暂停”订单的新订单电子邮件通知 - Woocommerce new order email notification to admin for "On Hold" orders 将客户email和“订单”栏中的电话添加到Woocommerce的管理订单列表中 - Add customer email and phone in "Order" column to admin orders list on Woocommerce 将新列中的客户电子邮件添加到 Woocommerce 上的管理订单列表 - Add customer email in a new column to admin orders list on Woocommerce 停止 WooCommerce 管理员 email 通知免费订单 - Stop WooCommerce admin email notification for free orders 在 Woocommerce 中下订单后,向管理员电子邮件通知添加附件 - Add an attachment to admin email-notification once order is placed in Woocommerce 在Woocommerce管理员“订单”列表上的自定义列中显示来自订单注释的交易ID - Display the transaction ID from order notes in a custom column on Woocommerce admin Orders list 自定义 PHP 剪辑器,用于向管理员发送电子邮件通知,以了解 WooCommerce 中的待处理订单状态,导致已处理订单的电子邮件重复 - Custom PHP snipper for email notification to the admin for pending order status in WooCommerce causing duplicated emails for processed orders 将订单总重量添加到WooCommerce新订单电子邮件通知中 - Add the order total weight to WooCommerce new order email notification 基于 Woocommerce 新订单通知的配送方式 ID 的电子邮件收件人 - Email recipients based on Shipping method Id for Woocommerce new order notification 仅针对具有处理状态的已付款订单发送 WooCommerce 新订单 email 通知 - Send WooCommerce New Order email notification only for paid orders with processing status
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM