mailchimp - Mailchimp API 和 mc:repeatable
问题描述
我正在使用 MailChimp Transactional API,但在填充使用 mc:repeatable 部分的电子邮件模板时遇到问题。我找不到有关如何执行此操作的任何文档或示例。这是使用https://mailchimp.com/developer/transactional/api/messages/send-using-message-template/的端点
这是我的电子邮件模板
<!DOCTYPE html>
<html lang="en">
<head>
<title>Your Order</title>
</head>
<body>
<div>Thanks for your order</div>
<div>Your receipt for your order from</div>
<div mc:edit="store_name">Store Name</div>
<div>Order Type</div>
<div mc:edit="order_type">Type</div>
<div>Products:</div>
<table>
<tr mc:repeatable="products">
<td mc:edit="quantity">Quantity</td>
<td mc:edit="product_name">Product Name</td>
<td mc:edit="price">Price</td>
</tr>
</table>
</body>
</html>
我可以在请求正文中mc:edit
使用它来填充所有区域:template_content
const content = [
{
name: 'store_name',
content: 'Any Store Name'
},
{
name: 'order_type',
content: 'Pickup Order'
},
{
name: 'subtotal',
content: '$80.00'
},
{
name: 'taxes',
content: '$2.22'
},
{
name: 'fees',
content: '$0.00'
},
{
name: 'total',
content: '$82.22'
}
]
quantity
如果我添加对象,我什至可以在可重复部分中填充单行product_name
,price
但我需要能够重复此部分并添加多个数量 > 产品名称 > 价格行。
任何建议或帮助或文档都会很棒,谢谢!
解决方案
从MailChimp 模板语言参考中,似乎不<tr>
支持元素mc:repeatable
。请参阅第三点(粗体)并注意,虽然<table>
是块级元素,<tr>
但不是。
mc:可重复
mc:repeatable
用于为模板中的特定元素提供复制操作。- 语法:
mc:repeatable
.- 用于
mc:repeatable
块级元素(如<div>
和<p>
),但列表或内联元素(如<img>
、<a>
和<span>
)除外。mc:repeatable
元素可以相互嵌套,但如果要这样做,请小心。我们不鼓励这种用途。mc:repeatable
可以在与 相同的元素上使用mc:edit
,但嵌套mc:repeatable
在下面mc:edit
将呈现可编辑但不可重复的内容。- 如果要将样式应用于可重复容器元素或可重复容器中的元素,请使用类或内联应用它们。不要使用 id 属性。
如果它们确实有效,您可能需要mc:variant
为子字段使用和每个产品的名称。像这样的东西:
<table>
<tr mc:repeatable="products" mc:variant="product1">
<td mc:edit="product1_quantity">Quantity</td>
<td mc:edit="product1_product_name">Product Name</td>
<td mc:edit="product1_price">Price</td>
</tr>
<tr mc:repeatable="products" mc:variant="product2">
<td mc:edit="product2_quantity">Quantity</td>
<td mc:edit="product2_product_name">Product Name</td>
<td mc:edit="product2_price">Price</td>
</tr>
<tr mc:repeatable="products" mc:variant="product3">
<td mc:edit="product3_quantity">Quantity</td>
<td mc:edit="product3_product_name">Product Name</td>
<td mc:edit="product3_price">Price</td>
</tr>
</table>
const content = [
{
name: 'product1_quantity',
content: '5'
}, {
name: 'product1_name',
content: 'Some Product'
}, {
name: 'product1_price',
content: '$49.99'
},
{
name: 'product2_quantity',
content: '1'
}, {
name: 'product2_name',
content: 'Some Other Product'
}, {
name: 'product2_price',
content: '$1,200'
},
{
name: 'product3_quantity',
content: '13'
}, {
name: 'product3_name',
content: 'Some Third Product'
}, {
name: 'product3_price',
content: '$17.50'
}
];
如果这看起来不是用于从动态数据构建列表,那是因为我不认为它是。看起来它是一种轻松将样式导入 Campaign Builder 的工具。
在构建器内部,有一个Product
概念,其中包括您希望在电子邮件中发送的信息类型。构建器的教程表明,虽然Product
部分是可重复的,但您需要将数据源连接到构建器,并且必须Products
在设计时选择要包含的数据源。
使用产品内容块从您连接的在线商店添加项目。每个块都设计为包含产品名称、自定义描述、价格和号召性用语按钮。如果您在电子邮件设置中打开电子商务跟踪,您的报告将显示购买收入。
要使用产品块,请按照以下步骤操作。
- 单击产品块或将其添加到您的电子邮件中。如果您正在使用现有块,请跳至步骤 4。
- 在选择商店模式中,选择要从中添加产品的商店。如果您尚未连接商店,系统会提示您这样做。
- 单击要添加的产品。
- 在产品菜单中,根据需要编辑标题、按钮和指向 URL 的链接。您还可以单击编辑图标选择不同的产品,或单击设置图标检查您的商店连接。
推荐阅读
- java - Socket 程序中的错误,它发送空白消息并且在每条消息之前都有一些奇怪的符号
- javascript - JavaScript上的DOM操作实践---请帮助
- networking - 使用 Go-Back-N 的 ACK 号是多少?
- c# - 读取列表中包含重复数据的所有数据
- android - 将我的motog plus更新为orieo后,热点说没有互联网
- django - 夹层模板如何工作?
- python - Python json 抓取我的日期为 'DueDate': '/Date(1539205200000)/' 。我没有得到日期格式
- reactjs - 启动 create-react-app 项目期间出现未处理的错误
- eclipse - 如何在 Spring Tools 4 for Eclipse 中更改终端字体颜色
- python - Tensorflow:训练数据集中的每一行都包含之前行数据的 99%——我可以在运行训练之前对其进行优化吗?