我对 WordPress 非常陌生,并且已经使用 WooCommerce 创建了一个电子商务商店。
客户下订单后,我收到一封电子邮件,客户收到一封电子邮件——一封让我说他们订购了什么,另一封作为感谢电子邮件给他们。
在这封感谢邮件中,在我的functions.php 文件中,我学会了更改标题的主题以包含其名称,例如:
//add the first name of the person to the person getting the reciept in the subject of the email.
add_filter('woocommerce_email_subject_customer_processing_order','UEBC_change_processing_email_subject', 10, 2);
function UEBC_change_processing_email_subject( $subject, $order ) {
global $woocommerce;
$subject = 'Thanks for your ' . get_bloginfo( 'name', 'display' ) . ' Order, '.$order->billing_first_name .'!';
return $subject;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码片段工作正常,并且只显示给客户,而不是我。例如“感谢您订购 ABCD 服装订购约翰!”。在电子邮件的正文中,我试图将其作为一个简短的感谢消息来个人化,但是,当我发送消息时,我使用了钩子:
add_action( 'woocommerce_email_before_order_table', 'custom_add_content', 20,1 );
Run Code Online (Sandbox Code Playgroud)
我知道因为我使用了woocommerce_email_before_order_table钩子,所以自定义函数将在电子邮件正文中发送给客户和我自己。
我想知道,Woocommerce 是否提供了一个钩子,以便自定义功能只会在电子邮件正文中发送给客户?
例如:woocommerce_email_header_customer_processing_order或者有那个意思的词?
谢谢
我有一个函数,它接受表达式并将变量替换为我用作输入的值的所有排列。这是我已经测试并可以正常工作的代码,但是,在仔细研究了SO之后,人们说嵌套的for循环是一个坏主意,但是我不确定如何提高效率。有人可以帮忙吗?谢谢。
def replaceVar(expression):
eval_list = list()
a = [1, 8, 12, 13]
b = [1, 2, 3, 4]
c = [5, 9, 2, 7]
for i in expression:
first_eval = [i.replace("a", str(j)) for j in a]
tmp = list()
for k in first_eval:
snd_eval = [k.replace("b", str(l)) for l in b]
tmp2 = list()
for m in snd_eval:
trd_eval = [m.replace("c", str(n)) for n in c]
tmp2.append(trd_eval)
tmp.append(tmp2)
eval_list.append(tmp)
print(eval_list)
return eval_list
print(replaceVar(['b-16+(c-(a+11))', 'a-(c-5)+a-b-10']))
Run Code Online (Sandbox Code Playgroud) 我正在学习Java JDBC,并且正在使用循环将数据存储到数据库(mySQL db)中.当我存储个人的名字和姓氏时,它似乎工作正常,但当我尝试插入电子邮件地址时,我收到以下错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法中有错误; 检查与您的MySQL服务器版本对应的手册,以便在"@ 123.com"附近使用正确的语法
据我所知,除非我遗漏了一些不可思议的东西,否则我无法看到我所犯的语法错误?
我的代码如下:
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Driver {
public static void main(String[] args) {
try{
Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:8889/demo","root","root");
Statement myStmt = myConn.createStatement();
ArrayList<String> firstNames = new ArrayList<String>(Arrays.asList("James", "John","Mark"));
ArrayList<String> lastNames = new ArrayList<String>(Arrays.asList("Handly", "licks","manford"));
ArrayList<String> emails = new ArrayList<String>(Arrays.asList("james@123.com", "John@45.co.uk","Markus@marc.com"));
for (int i = 0; i < firstNames.size(); i++){
String sql = "INSERT INTO EMPLOYEES (first_name,last_name,email) VALUES (" + firstNames.get(i)+ ", " + lastNames.get(i) + ", " + emails.get(i) …Run Code Online (Sandbox Code Playgroud)