doukang5966907 2017-03-01 08:55
浏览 19
已采纳

WooCommerce - 如何在电子邮件中将送货地址更改为N / A?

WooCommerce provides various hooks and action to change the predefined templates. But i need to hide the shipping address from order emails and display N/A. I have created a custom shipping method using plugin. Using that plugin i have to changed the address. Any help will be appreciated.

enter image description here

  • 写回答

1条回答 默认 最新

  • dongliao1949 2017-03-01 12:01
    关注

    Finally, i found a solution :

    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;
    
        }
    

    The normal WooCommerce template loader searches the following locations in order:

    1. your theme / template path / template name
    2. your theme / template name
    3. your plugin / woo-commerce / template name
    4. default path / template name

    Reference Link : https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含