仅显示已完成订单状态电子邮件通知的条形码
Displaying barcodes for completed order status email notification ONLY
在我的 WooCommerce 网站上,我使用 Woocommerce Order Barcodes 在电子邮件通知上显示订单条形码。
我想隐藏或删除此条形码并在仅 已完成 订单状态电子邮件通知中显示它。
我试过编辑插件文件(我知道不推荐这样做)。我在 class-woocommerce-order-barcodes.php
插件文件中删除了这个(第 128 - 129 行):
// Add barcode to order complete email
add_action( 'woocommerce_email_after_order_table', array( $this, 'get_email_barcode' ), 1, 1 );
但它会从所有电子邮件通知中删除条形码。
如何从电子邮件通知中删除这些条形码并仅在完成的电子邮件通知中显示?
谢谢
为了使其仅适用于已完成的订单状态电子邮件通知,只需在 IF 语句中添加这个小条件:
$order->has_status( 'completed' )
所以你可以先这样试试:
if (!$this->has_status( 'completed' ) ){
add_action( 'woocommerce_email_after_order_table', array( $this, 'get_email_barcode' ), 1, 1 );
}
但是因为我不确定在那里得到 $order 对象 ($this),所以我进一步查看了这个插件的代码。
At line 358 you have the code below where I have add the condition.
/**
* Get barcode for display in an email
* @access public
* @since 1.0.0
* @param object $order Order object
* @return void
*/
public function get_email_barcode ( $order ) {
if( ! $order ) return;
// HERE is my condition <==== <==== <==== <==== <==== <==== <====
if (!$order->has_status( 'completed' ) ) return;
// Generate correctly formatted HTML for email
ob_start(); ?>
// … / …
// code of the function continues …
我很确定这会起作用,因为我已经得到了 $order
对象。唯一的问题是每次更新该插件时都必须再次添加此代码。
As this is untested, I am not sure that it will work. Please give me a feed back on it
在我的 WooCommerce 网站上,我使用 Woocommerce Order Barcodes 在电子邮件通知上显示订单条形码。
我想隐藏或删除此条形码并在仅 已完成 订单状态电子邮件通知中显示它。
我试过编辑插件文件(我知道不推荐这样做)。我在 class-woocommerce-order-barcodes.php
插件文件中删除了这个(第 128 - 129 行):
// Add barcode to order complete email
add_action( 'woocommerce_email_after_order_table', array( $this, 'get_email_barcode' ), 1, 1 );
但它会从所有电子邮件通知中删除条形码。
如何从电子邮件通知中删除这些条形码并仅在完成的电子邮件通知中显示?
谢谢
为了使其仅适用于已完成的订单状态电子邮件通知,只需在 IF 语句中添加这个小条件:
$order->has_status( 'completed' )
所以你可以先这样试试:
if (!$this->has_status( 'completed' ) ){
add_action( 'woocommerce_email_after_order_table', array( $this, 'get_email_barcode' ), 1, 1 );
}
但是因为我不确定在那里得到 $order 对象 ($this),所以我进一步查看了这个插件的代码。
At line 358 you have the code below where I have add the condition.
/**
* Get barcode for display in an email
* @access public
* @since 1.0.0
* @param object $order Order object
* @return void
*/
public function get_email_barcode ( $order ) {
if( ! $order ) return;
// HERE is my condition <==== <==== <==== <==== <==== <==== <====
if (!$order->has_status( 'completed' ) ) return;
// Generate correctly formatted HTML for email
ob_start(); ?>
// … / …
// code of the function continues …
我很确定这会起作用,因为我已经得到了 $order
对象。唯一的问题是每次更新该插件时都必须再次添加此代码。
As this is untested, I am not sure that it will work. Please give me a feed back on it