Php WooCommerce-我们如何将发货地址更改为N/A以便发送电子邮件?
WooCommerce提供了各种钩子和操作来更改预定义的模板。但是我需要从订单电子邮件中隐藏发货地址并显示N/A。我已经使用插件创建了一个自定义发货方法。使用该插件,我必须更改地址。 任何帮助都将不胜感激Php WooCommerce-我们如何将发货地址更改为N/A以便发送电子邮件?,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,WooCommerce提供了各种钩子和操作来更改预定义的模板。但是我需要从订单电子邮件中隐藏发货地址并显示N/A。我已经使用插件创建了一个自定义发货方法。使用该插件,我必须更改地址。 任何帮助都将不胜感激 最后,我找到了一个解决方案: function myplugin_plugin_path() { return untrailingslashit( plugin_dir_path( __FILE__ ) ); } add_filter( 'woocommer
最后,我找到了一个解决方案:
function myplugin_plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
add_filter( 'woocommerce_locate_template', 'myplugin_woocommerce_locate_template', 10, 3 );
function myplugin_woocommerce_locate_template( $template, $template_name, $template_path ) {
global $woocommerce;
$_template = $template;
if ( ! $template_path ) $template_path = $woocommerce->template_url;
$plugin_path = myplugin_plugin_path() . '/woocommerce/';
$template = locate_template( array(
$template_path . $template_name,
$template_name));
// Modification: Get the template from this plugin, if it exists
if ( ! $template && file_exists( $plugin_path . $template_name ) )
$template = $plugin_path . $template_name;
// Use default template
if ( ! $template )
$template = $_template;
return $template;
}
普通WooCommerce模板加载程序按顺序搜索以下位置:
您的主题/模板路径/模板名称
您的主题/模板名称
您的插件/woo commerce/模板名称
默认路径/模板名称
参考链接: