Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Woocommerce退款电子邮件_Php_Wordpress_Woocommerce - Fatal编程技术网

Php Woocommerce退款电子邮件

Php Woocommerce退款电子邮件,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我做了大量的搜索,虽然我发现有用户询问如何实现以下目标,但据我所知,没有任何可行的解决方案 问题是关于非常流行的WoodPress插件“Woocommerce”。该插件附带一个电子邮件系统,使电子商务网站所有者和客户的生活更加轻松。一个问题是,当商店经理将订单状态更改为“退款”时,不会发送电子邮件。有人说这是因为这是一个手动过程。这是真的,这是一个过程,店主会通过那里的商户帐户或贝宝帐户。但一旦完成,店主就会登录到他们的wordpress管理面板,将订单状态更改为退款,这将有利于生成电子邮件并发

我做了大量的搜索,虽然我发现有用户询问如何实现以下目标,但据我所知,没有任何可行的解决方案

问题是关于非常流行的WoodPress插件“Woocommerce”。该插件附带一个电子邮件系统,使电子商务网站所有者和客户的生活更加轻松。一个问题是,当商店经理将订单状态更改为“退款”时,不会发送电子邮件。有人说这是因为这是一个手动过程。这是真的,这是一个过程,店主会通过那里的商户帐户或贝宝帐户。但一旦完成,店主就会登录到他们的wordpress管理面板,将订单状态更改为退款,这将有利于生成电子邮件并发送给客户

这是我见过的

所以我决定修改一个教程

我正在尝试在订单状态更新为“退款”时发送电子邮件

下面是初始插件文件的代码

<?php
/**
 * Plugin Name: WooCommerce Custom Expedited Order Email
 * Plugin URI: http://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
 * Description: Demo plugin for adding a custom WooCommerce email that sends admins an email when an order is received with expedited shipping
 * Author: SkyVerge
 * Author URI: http://www.skyverge.com
 * Version: 0.1
 *
 * License: GNU General Public License v3.0
 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
 *
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 *  Add a custom email to the list of emails WooCommerce should load
 *
 * @since 0.1
 * @param array $email_classes available email classes
 * @return array filtered available email classes
 */
function add_expedited_order_woocommerce_email( $email_classes ) {

    // include our custom email class
    require( 'includes/class-wc-expedited-order-email.php' );

    // add the email class to the list of email classes that WooCommerce loads
    $email_classes['WC_Expedited_Order_Email'] = new WC_Expedited_Order_Email();

    return $email_classes;

}
add_filter( 'woocommerce_email_classes', 'add_expedited_order_woocommerce_email' );
这些是我的插件中仅有的2个文件。我已经激活了它,它作为电子邮件出现在woo commerce电子邮件选项卡的电子邮件列表中。不幸的是,订单状态更新时没有发送电子邮件

有人能告诉我为什么这不起作用吗

我收到了一个人的一些反馈,他说:

“添加触发器的操作用于处理订单状态更改的挂起/失败- 您希望这些操作与退款订单相关,例如:添加_操作(“woocommerce_order_status_Returned”,数组($this,'trigger'));(查看woocommerce电子邮件类的确切信息)“


我使用的是Woocommerce 2.1.12

我想问题是你在打电话

add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) );
请尝试拨打:

add_action( 'woocommerce_order_status_refunded', array( $this, 'trigger' ) );

主要问题是,
woocommerce\u order\u status\u returned
挂钩默认情况下未注册到
send\u transactional\u email
回调,因此当订单状态更改为returned时,您无法使用上述方法自动发送电子邮件

您可以通过以下操作更改此设置:

/**
 * Register the "woocommerce_order_status_refunded" hook which is necessary to
 * allow automatic email notifications when the order is changed to refunded.
 * 
 * @see http://stackoverflow.com/a/26413223/2078474
 */
add_action( 'woocommerce_init', function() {
    add_action( 
        'woocommerce_order_status_refunded', 
        array( WC(), 'send_transactional_email' ),
        10, 
        10 
    );
});
另外,请确保您已在“Woo设置->电子邮件”选项卡的相应部分启用它:

默认情况下,为自动电子邮件通知注册以下操作:

woocommerce_low_stock
woocommerce_no_stock
woocommerce_product_on_backorder
woocommerce_order_status_pending_to_processing
woocommerce_order_status_pending_to_completed
woocommerce_order_status_pending_to_on-hold
woocommerce_order_status_failed_to_processing
woocommerce_order_status_failed_to_completed
woocommerce_order_status_completed
woocommerce_new_customer_note
woocommerce_created_customer
更新: 好消息,@helgatheviking刚刚合并了她的WooCommerce请求(见下面的评论)

这意味着我们应该能够使用新的
woocommerce\u email\u actions
过滤器:

add_filter( 'woocommerce_email_actions', function( $email_actions ) {
    $email_actions[] = 'woocommerce_order_status_refunded';
    return $email_actions;
});
在WooCommerce 2.3+中


类似的操作也适用于其他非默认电子邮件操作,如
woocommerce\u order\u status\u cancelled

@zen提出了建议的解决方案:
add\u action('woocommerce\u order\u status\u returned',array($this,'trigger')\uu construct()
方法中的code>不适合你吗?@birgire-yep刚刚试过。不行。如果你愿意,你可以花18美元解决这个问题,并获得额外的功能。我和这家公司没有关系@Len_D,我不介意付18美元,但这是我不想要的整个争议系统。最坏的情况是你可以看到他如何执行通知并编写你自己的函数。如果你付钱给他买插件就不会犯规。我已经试过了,但还是不行。没有电子邮件发送。@zen我认为如果你把birgire的答案和这个结合起来,你应该能够让它工作,但你需要它们。很好的捕获。但是你不能简单地做添加动作('woocommerce\u order\u status\u Returned',数组(WC(),'send\u transactional\u email'),10,10)@禅宗:这个答案加上@len_D关于更新触发器的建议应该可以做到。@helgatheviking谢谢,这是一个有趣的难题需要解决;-)经过一些尝试和错误后,此解决方案似乎适用于我的安装。我之所以将其包装到
woocommerce\u init
操作回调中,是为了避免
WC()
成为未定义的函数,如果您的插件在woocommerce插件之前运行,并且包含您建议的简单操作调用,则可能会发生这种情况。我已经开始命名函数
so\u 25544762()
或stackoverflow中的任何ID。这确保了它们的独特性,而不需要任何创造性。核心中可能应该有一个过滤器来添加/删除电子邮件触发器。如果有人向Woo发送拉请求,他们可能会将其添加进来。我有点惊讶退款邮件已经不在核心里了。它已经被合并了!所以它应该可以在WC2.3中使用。不管我怎么想。此操作
add_操作('woocommerce_init',function(){add_操作('woocommerce_order_status_returned',数组(WC(),'send_transactional_email'),10,10);}
需要在主插件文件中,而不是在email类中。
add_filter( 'woocommerce_email_actions', function( $email_actions ) {
    $email_actions[] = 'woocommerce_order_status_refunded';
    return $email_actions;
});