2017-03-01 3 views
0

WooCommerceは、定義済みのテンプレートを変更するためのさまざまなフックとアクションを提供します。しかし、私は注文電子メールと表示N/Aから配送先住所を非表示にする必要があります。私はプラグインを使用してカスタム配送方法を作成しました。そのプラグインを使用して私はアドレスを変更する必要があります。 助けていただければ幸いです。WooCommerce - 配送先住所をメールでN/Aに変更するにはどうすればよいですか?

enter image description here

答えて

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. プラグイン/ウーコマース/テンプレート名
  4. デフォルトのパス/テンプレート名

参考リンク:https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/

関連する問題