Displaying batch info in order confirmation emails

Shopify's Order confirmation email usually can't show Freshly batch details because Shopify sends it at the same moment it tells Freshly about the new order. Freshly assigns batches and saves them to the order a few moments later. Add the batch details to emails that go out later instead, such as Shipping confirmation, or resend the confirmation after batches are assigned.

Before you start

Turn on order metafields in Freshly: go to Preferences > Order fulfillment, check Enable inventory batch metafields on customer orders, and click Save. This is part of the paid Freshly plan. See Adding batch details in metafields to Shopify orders.

Options
  • Use a later email. Shipping confirmation and other shipping and delivery emails are sent after Freshly has assigned batches
  • Resend the order confirmation. If you resend it from the order page after a few minutes, the batch details are included

Add batch details to the Shipping confirmation email

  1. In your Shopify admin, go to Settings > Notifications.
  2. Click Customer notifications, then Shipping confirmation.
  3. Click Edit code. Copy the existing code somewhere safe first, as reverting a template can't restore your edits.
  4. Find the line {% for line in fulfillment.fulfillment_line_items %} .
  5. Inside that loop, where you want batch details to appear (for example, under the product title), paste:
{% assign inventory_batches = order.metafields.freshly.inventory_batches %}
{% for inventory_batch in inventory_batches %}
  {% if line.line_item.id == inventory_batch.line_item_id %}
    <p>
      <span class="item-description-line">Batch: {{ inventory_batch.batch_name }}</span>
      {% unless inventory_batch.expiry_date == blank %}
        <span class="item-description-line">Expiry date: {{ inventory_batch.expiry_date | date: "%b %d, %Y" }}</span>
      {% endunless %}
      {% unless inventory_batch.description == blank %}
        <span class="item-description-line">{{ inventory_batch.description }}</span>
      {% endunless %}
    </p>
  {% endif %}
{% endfor %}
  1. Click Save, then click Preview to check the layout.

You can use other batch fields too, such as batch_number , received_date , location_name  and quantity .

If you'd like help adding this to your emails, contact us at hello@getfreshly.io.

Still need help? Contact Us Contact Us