【问题标题】:WooCommerce - Replace Shipping Label in email templateWooCommerce - 替换电子邮件模板中的运输标签
【发布时间】:2018-09-23 19:13:21
【问题描述】:

也许这是重复的,但我真的很难在 Google、Stackoverflow 等的任何地方找到它。

我在 WooCommerce 更改电子邮件模板时总是遇到问题,这非常烦人且不方便用户使用。但我的问题是,我可以在哪里或如何更改客户和管理员收到的电子邮件模板中的“运输”标签?

我需要添加一些钩子还是可以在 php 文件中替换它?

我已经搜索了 php 文件,但找不到...

有人有想法吗?

【问题讨论】:

    标签: wordpress templates woocommerce hook-woocommerce


    【解决方案1】:

    在 Woo-commerce 中发送了许多电子邮件,还有一些模板可以将特定的订单数据提取到电子邮件本身中。要找到这些模板,您可以访问:

    woocommerce/templates/emails/(位于插件文件夹中)

    此时您要做的基本上是复制您要编辑的电子邮件模板,并将它们保存在以下位置:your_theme/woocommerce/emails/。这实际上是为 Woo-commerce 使用的主模板创建一个子模板,这样在插件更新的情况下,您不会丢失对相应电子邮件模板所做的任何更改。

    如果您希望...例如编辑下新订单时管理员收到的电子邮件,此模板位于此处(在您的插件文件夹中)woocommerce/templates/emails/admin-new-order.php

    这是来自各个模板的实际代码,因此您知道您找到了我提到的正确代码:

    <?php
    /**
     * Admin new order email
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-new-order.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see         https://docs.woocommerce.com/document/template-structure/
     * @author WooThemes
     * @package WooCommerce/Templates/Emails/HTML
     * @version 2.5.0
     */
    
     if ( ! defined( 'ABSPATH' ) ) {
        exit;
     }
    
     /**
      * @hooked WC_Emails::email_header() Output the email header
      */
     do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
    
     <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>
    
     <?php
    
     /**
      * @hooked WC_Emails::order_details() Shows the order details table.
      * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
      * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
      * @since 2.5.0
      */
     do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
    
     /**
      * @hooked WC_Emails::order_meta() Shows order meta data.
      */
     do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
    
     /**
      * @hooked WC_Emails::customer_details() Shows customer details
      * @hooked WC_Emails::email_address() Shows email address
      */
     do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
    
     /**
      * @hooked WC_Emails::email_footer() Output the email footer
      */
     do_action( 'woocommerce_email_footer', $email );
    

    请记住,这些模板本身仍有许多钩子,您可能必须根据您要在模板中实际更改的内容进行钩子,但大多数情况下,因为您现在知道在哪里可以找到它们,这应该相对简单。

    希望这会有所帮助!祝你好运:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 2012-03-31
      相关资源
      最近更新 更多