2016-08-13 185 views

回答

2

是有可能(查看更新這個頁面的底部) ...

overriding WooCommerce templates(複製WooCommerce插件templates文件夾到您的活動子主題或主題,將其重命名爲woocommerce)。
那請be sure to read the related docs第一個

一旦上面做得正確,你必須編輯位於該woocommerce文件夾活動的子主題或主題裏2個模板。該文件位於:

  1. emails(sub folder)>email-addresses.php(php file)

    從線19替換該模板的代碼:
if (! defined('ABSPATH')) { 
    exit; 
} 

?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0"> 
    <tr> 
     <td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%"> 
      <h3><?php _e('Billing address', 'woocommerce'); ?></h3> 

      <p class="text"><?php echo $order->get_formatted_billing_address(); ?></p> 
     </td> 
     <?php // ======================> Here begins the customization 

      $shipping_local_pickup = false; 
      if ($items_totals = $order->get_order_item_totals()) { 
       foreach ($items_totals as $items_total) { 
        if ($items_total['value'] == 'Local Pickup' && !$shipping_local_pickup) $shipping_local_pickup = true; 
       } 
      } 
      // End 

      if (! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ($shipping = $order->get_formatted_shipping_address()) && !$shipping_local_pickup) : ?> 
      <td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%"> 
       <h3><?php _e('Shipping address', 'woocommerce'); ?></h3> 

       <p class="text"><?php echo $shipping; ?></p> 
      </td> 
     <?php endif; ?> 
    </tr> 
</table> 
  • emails(sub folder)>plain(sub folder)>email-addresses.php(php file)
  • if (! defined('ABSPATH')) { 
        exit; 
    } 
    
    echo "\n" . strtoupper(__('Billing address', 'woocommerce')) . "\n\n"; 
    echo preg_replace('#<br\s*/?>#i', "\n", $order->get_formatted_billing_address()) . "\n"; 
    
    // ======================> Here begins the customization 
    
    $shipping_local_pickup = false; 
    if ($items_totals = $order->get_order_item_totals()) { 
        foreach ($items_totals as $items_total) { 
         if ($items_total['value'] == 'Local Pickup' && !$shipping_local_pickup) $shipping_local_pickup = true; 
        } 
    } // End 
    
    if (! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ($shipping = $order->get_formatted_shipping_address()) && !$shipping_local_pickup) { 
        echo "\n" . strtoupper(__('Shipping address', 'woocommerce')) . "\n\n"; 
        echo preg_replace('#<br\s*/?>#i', "\n", $shipping) . "\n"; 
    } 
    

    我已強制將此添加到檢測何時本地拾取的順序使用:

    $shipping_local_pickup = false; 
    if ($items_totals = $order->get_order_item_totals()) { 
        foreach ($items_totals as $items_total) { 
         if ($items_total['value'] == 'Local Pickup' && !$shipping_local_pickup) $shipping_local_pickup = true; 
        } 
    } 
    


    從線19替換該模板 的代碼

    而這在現有的if聲明停止發貨地址的顯示(本地接聽):

    && !$shipping_local_pickup 
    

    更新:可以使用** WC_Abstract_Order class - has_shipping_method()** method這種方式使用更緊湊的代碼

    $shipping_local_pickup = false; 
    if ($order->has_shipping_method('local_pickup')) 
        $shipping_local_pickup = true; 
    

    而這在現有的if聲明停止發貨地址的顯示(本地接聽):

    && !$shipping_local_pickup 
    

    參考文獻:

    +0

    如果我想使用更緊湊的模式,我編輯同一行同一個文件? – OHSM

    +0

    奇怪的是,我仍然在電子郵件html中看到「送貨地址」... – OHSM

    +0

    絕對的天才和偉大的人物。感謝您的幫助! – OHSM

    相關問題