简体   繁体   English

如何在 WooCommerce 中的已完成订单 email 模板中添加新帐户信息

[英]How to add new account info on order completed email template in WooCommerce

I'm trying to reduce the number of emails sent per order on one of my WooCommerce sites.我正在尝试减少我的 WooCommerce 网站之一上每个订单发送的电子邮件数量。

Right now, customers receive emails for现在,客户会收到电子邮件

  • New account created (unless they previously have one)创建新帐户(除非他们以前有一个)
  • Order Received收到订单
  • Order On Hold暂停订单
  • Order Completed.订单完成。

I've checked off the Order On Hold and Received emalls, so that takes me from four to two.我已经核对了待定订单和收到的电子邮件,所以我从四个变成了两个。


I want to display the account login info on the Order Completed email, so I can eliminate sending the Account Created email as well, but when I just copied over the code from the customer-new-account.php email template into the customer-completed-order.php email, the placeholders to list both the username and password become blank, which is quite odd.我想在 Order Completed email 上显示帐户登录信息,因此我也可以消除发送 Account Created email,但是当我刚刚将代码从customer-new-account.php email 模板复制到customer-completed-order.php email,列出用户名和密码的占位符都变成空白,这很奇怪。

This is the code I pasted over into my child theme's WooCommerce folder:这是我粘贴到子主题的 WooCommerce 文件夹中的代码:

<?php /* translators: %s Customer username */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $user_login ) ); ?></p>
<?php /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ ?>
<p><?php printf( __( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); ?></p><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>

<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) : ?>
    <?php /* translators: %s Auto generated password */ ?>
    <p><?php printf( esc_html__( 'Your password has been automatically generated: %s', 'woocommerce' ), '<strong>' . esc_html( $user_pass ) . '</strong>' ); ?></p>
<?php endif; ?>

The thing is that a new account is created immediately after clicking on the "confirm order" button.问题是在单击“确认订单”按钮后会立即创建一个新帐户。 The user is sent "your account has been created" with a username and password, and the password is written in encrypted form to the database.向用户发送“您的帐户已创建”以及用户名和密码,密码以加密形式写入数据库。

The message "completed order" will be sent much later. “已完成订单”消息将在很晚的时候发送。 This letter can no longer get the password from the database, because it is encrypted.这封信不能再从数据库中获取密码,因为它是加密的。 Therefore, it is useless to insert variables with a password into the template of the second letter.因此,在第二个字母的模板中插入带有密码的变量是没有用的。

This is some kind of moronic American system.这是某种愚蠢的美国制度。 In reality, you have to send 2 letters to the user, in which he simply can get confused, and we, the resource administrators, will then receive a claim, or we will persistently explain to the client how to get into the account.实际上,您必须向用户发送 2 封信,他很容易在信中感到困惑,然后我们资源管理员将收到索赔,或者我们会坚持不懈地向客户解释如何进入该帐户。

If it were a normal human system, a new account would be created at the moment of the completed order (well, it is logical. The person paid for and an account was created for him), And when an account is created in advance, at the stage of transition to payment.如果是正常的人类系统,在完成订单的那一刻,就会创建一个新账户(好吧,这是合乎逻辑的。支付的人为他创建了一个账户),而当一个账户被提前创建时,在过渡到付款的阶段。 this is the kind of system that the developers have created, A person just enters the card number into the payment system?这是开发人员创建的系统,一个人只需将卡号输入支付系统? and he has a letter like this - "here is your username-password! Come on in!"他有一封这样的信——“这是你的用户名密码!进来吧!” Where to come on!?哪里来的!? You did not payed yet!你还没有付款!

I'm trying to reduce the number of emails sent per order on one of my WooCommerce sites.我正在尝试减少在我的 WooCommerce 站点之一上每个订单发送的电子邮件数量。

Right now, customers receive emails for现在,客户收到电子邮件

  • New account created (unless they previously have one)创建了新帐户(除非他们以前有一个)
  • Order Received收到订单
  • Order On Hold订单暂停
  • Order Completed.订单完成。

I've checked off the Order On Hold and Received emalls, so that takes me from four to two.我已经检查了暂停订单和收到的电子邮件,所以这需要我从四个到两个。


I want to display the account login info on the Order Completed email, so I can eliminate sending the Account Created email as well, but when I just copied over the code from the customer-new-account.php email template into the customer-completed-order.php email, the placeholders to list both the username and password become blank, which is quite odd. I want to display the account login info on the Order Completed email, so I can eliminate sending the Account Created email as well, but when I just copied over the code from the customer-new-account.php email template into the customer-completed-order.php email,同时列出用户名和密码的占位符变为空白,这很奇怪。

This is the code I pasted over into my child theme's WooCommerce folder:这是我粘贴到我的子主题的 WooCommerce 文件夹中的代码:

<?php /* translators: %s Customer username */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $user_login ) ); ?></p>
<?php /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ ?>
<p><?php printf( __( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); ?></p><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>

<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) : ?>
    <?php /* translators: %s Auto generated password */ ?>
    <p><?php printf( esc_html__( 'Your password has been automatically generated: %s', 'woocommerce' ), '<strong>' . esc_html( $user_pass ) . '</strong>' ); ?></p>
<?php endif; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM