WooCommerce: создайте собственную электронную почту - PullRequest
0 голосов
/ 22 января 2019

Я пытаюсь создать письмо с напоминанием об отзыве, используя Счет клиента / Детали заказа .Мы не используем это электронное письмо, поэтому я подумал, что было бы неплохо изменить код, чтобы сделать его электронным письмом с напоминанием о проверке, а затем мы могли бы вызвать его вручную.

Я немного изменил код, так что теперьвыглядит так:

<?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. A статическое изображение , ниже заголовка, указывая на изображение вбиблиотека мультимедиа.
  2. A URL-ссылка на конкретный приобретенный продукт.
  3. Этот запрос дает мне название продукта (и изображение), количество и цену.Я хочу избавиться от количества и цены и просто иметь имя и изображение.

Хотя я не хочу связываться с основным кодом шаблона электронной почты, поэтому я хочу иметь возможность сделать этовсе это в одном php файле.

Может кто-нибудь посоветовать какой-нибудь из этих трех пунктов?Спасибо!

1 Ответ

0 голосов
/ 23 января 2019

Скопируйте email-order-items.php формуляр плагинов / woocommerce / templates / emails / в wp-content / themefolder / woocommerce / emails / email-order-item.php тем самым вы можете редактировать макет вашей электронной почты, не затрагивая основные функции woocommerce. Детали уже там, включая изображение и заголовок.

...