【问题标题】:Mailchimp API and mc:repeatableMailchimp API 和 mc:repeatable
【发布时间】:2021-11-16 09:46:55
【问题描述】:

我正在使用 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>

我可以使用它作为请求正文中的template_content 填充所有mc:edit 区域:

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'
                }
            ]

如果我为 quantityproduct_nameprice 添加对象,我什至可以在可重复部分中填充单行,但我需要能够重复此部分并添加多个数量 > 产品名称 > 价格行.

任何建议或帮助或文档都会很棒,谢谢!

【问题讨论】:

    标签: mailchimp mailchimp-api-v3.0 mailchimp-api-v3


    【解决方案1】:

    MailChimp template language reference 来看,mc:repeatable 似乎不支持&lt;tr&gt; 元素。请参阅第三个(粗体)点并注意,&lt;table&gt; 块级元素,&lt;tr&gt; is not

    mc:可重复

    • mc:repeatable 用于为模板中的特定元素提供复制操作。
    • 语法:mc:repeatable
    • 在块级元素(如&lt;div&gt;&lt;p&gt;)上使用mc:repeatable,但列表或内联元素(如&lt;img&gt;&lt;a&gt;&lt;span&gt;)除外。
    • mc:repeatable 元素可以相互嵌套,但如果要这样做,请小心。我们不鼓励这种用途。
    • mc:repeatable 可用于与 mc:edit 相同的元素,但在 mc:edit 下方嵌套 mc:repeatable 将呈现可编辑但不可重复的内容。
    • 如果要将样式应用于可重复容器元素或可重复容器中的元素,请使用类或内联应用它们。不要使用 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'
        }
    ];
    

    如果这看起来不是用于从动态数据构建列表,那是因为我认为它不是。好像是tool for easily getting styles into the Campaign Builder

    在构建器内部,有一个 Product 概念,其中包含您希望在电子邮件中发送的信息类型。 The tutorial for the builder 表示虽然 Product 部分是可重复的,但您需要将数据源连接到构建器,并且必须在设计时选择要包含的 Products

    使用产品内容块从您的connected online store 添加项目。每个块都设计为包含产品名称、自定义描述、价格和号召性用语按钮。如果您在电子邮件设置中打开电子商务跟踪,您的报告将显示购买收入。

    要使用产品块,请按以下步骤操作。

    1. 单击产品块或将其添加到您的电子邮件中。如果您正在使用现有块,请跳至第 4 步。
    2. 在“选择商店”模式中,选择要从中添加产品的商店。如果您尚未关联商店,系统会提示您关联。
    3. 点击您要添加的产品。
    4. 在产品菜单中,根据需要编辑标题、按钮和指向 URL 的链接。您也可以点击编辑图标选择不同的产品,或点击设置图标检查您的商店连接。

    【讨论】:

      猜你喜欢
      • 2019-05-10
      • 2021-03-21
      • 1970-01-01
      • 2014-10-14
      • 1970-01-01
      • 2011-06-26
      • 2018-08-15
      • 2017-04-20
      • 2015-03-08
      相关资源
      最近更新 更多