2016-08-13 190 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

    相关问题