1

我正在尝试使用客户发票/订单详细信息电子邮件创建审查提醒电子邮件。我们不使用这封电子邮件,所以我认为最好更改代码以使其成为审查提醒电子邮件,然后我们可以手动触发它。

我更改了一些代码,所以现在看起来像这样:

<?php
/**
 * Customer completed order email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-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/
 * @package WooCommerce/Templates/Emails
 * @version 3.5.0
 */

if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

/*
 * @hooked WC_Emails::email_header() Output the email header
 */
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>


<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<p><?php printf( esc_html__("the more you share, the more you help other customers. We would love to know your thoughts on your most recent purchase and we'd appreciate it if you could take a moment to write a quick review.", 'woocommerce' ), esc_html( wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ); ?></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
 */

$text_align = is_rtl() ? 'right' : 'left';


  if ( $sent_to_admin ) {
    $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
    $after  = '</a>';
  } else {
    $before = '';
    $after  = '';
  }
  /* translators: %s: Order ID. */
  ?>
</h2>

<div style="margin-bottom: 40px;">
  <table class="td" cellspacing="0" cellpadding="0" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<tbody>
      <?php
      echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
        'show_sku'      => $sent_to_admin,
        'show_image'    => true,
        'image_size'    => array( 100, 100 ),
        'plain_text'    => $plain_text,
        'sent_to_admin' => $sent_to_admin,
      ) );
      ?>

    </tbody>
  </table>
</div>


<p>
<?php esc_html_e( 'Thanks for shopping with us.', 'woocommerce' ); ?>
</p>
<?php

/*
 * @hooked WC_Emails::email_footer() Output the email footer
 */
do_action( 'woocommerce_email_footer', $email );

不过,我需要添加 3 件事:

  1. 标题下方的静态图像,指向媒体库中的图像。
  2. 购买的特定产品的URL 链接。
  3. 这个查询给了我产品名称(和图片)、数量和价格。我想摆脱数量和价格,只拥有名称和图像。

不过,我不想弄乱主要的电子邮件模板代码,所以我希望能够在这个 php 文件中完成所有这些事情。

有人可以就这三个项目中的任何一个提供建议吗?谢谢!

4

1 回答 1

1

email-order-items.php表单plugins/woocommerce/templates/emails/ 复制到您的wp-content/themefolder/woocommerce/emails/email-order-item.php通过这样做,您可以编辑电子邮件的布局而无需触摸woocommerce的核心功能。详细信息已经存在,包括图像和标题。

于 2019-01-23T05:14:02.560 回答