Mailchimp API 和 mc:repeatable

Mailchimp API and 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>

我能够使用此作为请求正文中的 template_content 填充所有 mc:edit 区域:

const content = [
                {
                    name: 'store_name',
                    content: 'Any Store Name'
                },
                {
                    name: 'order_type',
                    content: 'Pickup Order'
                },
                {
                    name: 'subtotal',
                    content: '.00'
                },
                {
                    name: 'taxes',
                    content: '.22'
                },
                {
                    name: 'fees',
                    content: '[=13=].00'
                },
                {
                    name: 'total',
                    content: '.22'
                }
            ]

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

如果有任何建议或帮助或文档都将非常有用,谢谢!

来自MailChimp template language reference, it doesn't appear that <tr> elements are supported by mc:repeatable. See the third (bolded) point and note that, while <table> is a block level element, <tr> is not.

mc:repeatable

  • mc:repeatable is used to provide a duplication action for a particular element within a template.
  • Syntax: mc:repeatable.
  • Use mc:repeatable on block-level elements (like <div> and <p>) with the exception of lists, or inline elements (like <img>, <a>, and <span>).
  • mc:repeatable elements can be nested within each other, but use care if you’re going to do this. We don’t encourage this use.
  • mc:repeatable can be used on the same element as mc:edit, but nesting mc:repeatable beneath mc:edit will render content that is editable but not repeatable.
  • If you want to apply styles to repeatable container elements or elements within repeatable containers, either use class or apply them in-line. Don’t use the id attribute.

如果它们确实有效,您可能需要为子字段使用 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: '.99'
    }, 

    {
        name: 'product2_quantity',
        content: '1'
    }, {
        name: 'product2_name',
        content: 'Some Other Product'
    }, {
        name: 'product2_price',
        content: ',200'
    },

    {
        name: 'product3_quantity',
        content: '13'
    }, {
        name: 'product3_name',
        content: 'Some Third Product'
    }, {
        name: 'product3_price',
        content: '.50'
    }
];

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

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

Use Product content blocks to add items from your connected online store. Each block is designed to contain a product name, custom description, price, and call-to-action button. And if you turn on e-commerce tracking in your email settings, your report will show purchase revenue.

To use a Product block, follow these steps.

  1. Click a Product block or add one to your email. If you’re working with an existing block, skip to step 4.
  2. In the Select a store modal, choose the store you want to add products from. If you haven’t yet connected a store, you’ll be prompted to do so.
  3. Click the product you want to add.
  4. In the Products menu, edit the Title, Button, and Link to URL as needed. You can also click the edit icon to choose a different product, or click the settings icon to check your store connection.