我正在使用联系表格7来创建查询表格 .
在网站上,用户可以将任意数量的项目添加到购物篮中 . 我有一个页面,其中包含收集个人详细信息的表单,我也在该页面上输出购物篮数据(购物篮数据使用本地存储存储) .
我想通过电子邮件将查询发送给管理员,其中包括个人表单数据以及购物篮中每个项目的详细信息 .
我现在能想到的唯一方法是在表单中使用隐藏字段,将篮子项的HTML添加到此字段(使用JS):
// add data to input
var enquiryInput = $('textarea.order-input');
var enquiryInputVal = '';
// loop through each item
$.each(wishlist, function(i, item) {
$.each(item, function(key, value) {
if( key === 'ID' ) {
// do nothing
} else if( key === 'product' ) {
// remove hyphens and uppercase each word
key = key.replace(/-/g, ' ');
key = key.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
// add to string
enquiryInputVal += '<b>'+ key +': '+ value +'</b>
';
} else {
// remove hyphens and uppercase each word
key = key.replace(/-/g, ' ');
key = key.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
// add to string
enquiryInputVal += key +': '+ value +'
';
}
});
enquiryInputVal += '
';
});
// set value of hidden input to show wishlist in enquiry form
enquiryInput.val(enquiryInputVal);
...然后使用传统的CF7邮件标签 [order]
输出 .
数据显示,但它不会为字段呈现HTML(出于明显的安全原因,我猜)
例如(这是我在收件箱中的CF7 HTML电子邮件中获得的内容):
<b>Product: Product Title</b>
Quantity: 34
Comments: Suspendisse turpis felis, pretium sit amet mollis et, sollicitudin vel eros.
<b>Product: Product 2 Title</b>
Quantity: 164
Comments: Ut egestas consequat faucibus.
有没有人知道一种传递附加HTML和表单数据的方法,并且能够在CF7的Mail选项卡中访问它?我查看了文档,但我看不到一个似乎可行的钩子 .