我有一个用于管理我的货件的插件,具有两种自定义状态:等待装运和装运。
我尝试添加订单传递到发货时发送的电子邮件。
我在Stack Overflow上找到了这个:Woocommerce Refund Email 但我可以看出它是如何工作的
这是我的插件文件代码:
我根据helgatheviking和Adrien Leber的建议更新了我的代码
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var tsify = require('tsify');
var gutil = require('gulp-util');
var watch = require('gulp-watch');
var watchedBrowserify = watchify(browserify({
basedir: '.',
debug: true,
entries: "src/main.ts",
cache: {},
packageCache: {}
}).plugin(tsify));
gulp.task('ts:watch', bundle);
function bundle() {
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist'));
}
gulp.task('default', ['ts:watch']);
watchedBrowserify.on('update', bundle);
watchedBrowserify.on('log', gutil.log);
我的班级:
function shippement_tracking_filter_actions( $actions ){
$actions[] = "woocommerce_order_status_shipped";
return $actions;
}
add_filter( 'woocommerce_email_actions', 'shippement_tracking_filter_actions' );
function add_expedited_order_woocommerce_email( $email_classes ) {
require( 'includes/class-wc-expedited-order-email.php' );
$email_classes['WC_Expedited_Order_Email'] = new WC_Expedited_Order_Email();
return $email_classes;
}
add_filter( 'woocommerce_email_classes', 'add_expedited_order_woocommerce_email' );`
当我更改订单状态时,没有任何反应!我的触发功能永远不会调用。
任何人都可以帮助我吗?
答案 0 :(得分:1)
我认为你误解了这一部分:
function add_expedited_order_woocommerce_email( $email_classes ) {
$email_classes['WC_Expedited_Order_Email'] = include( plugin_dir_path( __FILE__ ) . '/class-wc-expedited-order-email.php' );
return $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;
}
希望它有所帮助。