【问题标题】:WooCommerce - How can we change Shipping Address to N/A in order emails?WooCommerce - 我们如何在订单电子邮件中将送货地址更改为 N/A?
【发布时间】:2017-03-01 08:55:05
【问题描述】:

WooCommerce 提供了各种钩子和操作来更改预定义的模板。但我需要从订单电子邮件中隐藏收货地址并显示 N/A。我使用插件创建了一种自定义运输方式。使用该插件我必须更改地址。 任何帮助将不胜感激。

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    终于找到了解决办法:

    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 模板加载器按顺序搜索以下位置:

    1. 您的主题/模板路径/模板名称
    2. 您的主题/模板名称
    3. 您的插件/woo-commerce/模板名称
    4. 默认路径/模板名称

    参考链接:https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-06
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      • 2020-04-13
      • 2018-02-09
      • 2019-08-23
      • 1970-01-01
      相关资源
      最近更新 更多