Automated Shopify Order Line-Item Processing to Airtable Database - n8n Workflow

Use this robust n8n workflow to automatically capture new Shopify orders, break them down into individual line items, allocate shipping and tax costs, and synchronize the highly structured data into Airtable using an n8n upsert operation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • E-commerce businesses using Shopify and Airtable for CRM or inventory management.

  • Data analysts needing granular, product-level sales records rather than just order headers.

  • Users looking for advanced examples of how to use the n8n code node for complex data transformation.

  • Anyone seeking reliable n8n templates for real-time sales reporting and data synchronization.

Overview

Managing high-volume e-commerce sales data requires breaking down large order objects into manageable, product-specific rows for accurate reporting. This powerful n8n workflow solves the problem of integrating complex Shopify order data—which often contains multiple products, taxes, and shipping fees bundled together—into a clean, row-based Airtable database.

This specific n8n template uses custom JavaScript to perform financial allocations, ensuring that total tax and shipping costs are accurately distributed across individual product line items. This detailed breakdown is crucial for profit and loss analysis and streamlined inventory management, all automated via a reliable n8n process.

How it Works

This automation starts with a dedicated n8n trigger listening for Shopify order data.


  1. Shopify Order Trigger: The process begins when the Webhook n8n node is activated by a POST request, typically configured as a Shopify webhook for 'Order Created' events. This is the main n8n trigger.


  1. Data Extraction & Allocation (Code Node): The first Code n8n node executes complex JavaScript. It performs several critical functions:

a. Parses the incoming raw Shopify JSON.
b. Extracts and standardizes financial fields (Subtotal, Tax, Shipping, Discounts, Grand Total).
c. Iterates through all line_items in the order.
d. For each line item, it calculates the item's proportional weight of the total order value.
e. It then uses this weight to accurately allocate the total Tax (Allocated Tax) and Shipping costs (Allocated Shipping) to that specific product row.
f. The output is restructured so that one item is created for each product line item in the original order.


  1. Batch Processing: The Split in Batches n8n node prepares the resulting line items for individual processing, ensuring the Airtable API limits are respected and each product row is handled sequentially.


  1. Data Mapping (Set Node): The subsequent Set n8n node maps the custom fields generated by the Code n8n node (like 'Allocated Tax' and 'Line Total') to the target column names in the Airtable sheet.


  1. Serial Number Generation Logic: To provide an auto-incrementing serial number (S No), the n8n workflow temporarily retrieves all existing records from the target Airtable sheet (Order Sheeet). The next Code n8n node (Code23) extracts only the last record to find the current highest S No. A subsequent Code n8n node (Generating S No1) increments this serial number by one.


  1. Airtable Upsert: Finally, the last Airtable n8n node performs an upsert operation. It uses the Order ID as a matching column to ensure that if a line item for an order already exists (perhaps due to a previous run or modification), it is updated; otherwise, a new record is created using the newly generated, incremented S No and the detailed line-item data.

Installation Guide

To deploy this n8n template, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance via the 'New' menu > 'Import from JSON'.

  2. Set up the Webhook Trigger:

a. Activate the 'create order' Webhook n8n trigger node.
b. Copy the generated webhook URL.
c. In your Shopify store admin, go to Settings > Notifications > Webhooks. Create a new webhook pointing to this URL, listening for the 'Order creation' event.

  1. Airtable Credentials:

a. Create or use an existing Airtable Personal Access Token credential within your n8n settings.
b. In the Airtable n8n node (Order Sheeet and CustomerSheet), select your Airtable credential.
c. Specify the correct Base ID and the Table ID (named 'Order Sheet' in the template) that matches the fields defined in the Sheet and Edit Fields n8n nodes.

Node Details

create order (Webhook n8n trigger):
Function: Acts as the listener, waiting for external data (specifically, a Shopify 'orders/create' webhook event).
Key Configuration: Path is set to createorder and Method is POST.

Code (n8n node):
Function: Performs complex data transformation, financial allocation (tax/shipping per line item), and restructuring of the single order JSON into multiple records (one per product variant).
Key Configuration: Contains extensive JavaScript logic to ensure clean financial totals, address standardization, and product option extraction (Color, Size, Material).

Loop Over Items (Split in Batches n8n node):
Function: Takes the multiple line-item records outputted by the Code node and passes them through the subsequent steps one by one, ensuring each item gets a unique serial number and is inserted individually into Airtable.

Order Sheeet (Airtable n8n node):
Function: Searches the entire target Airtable 'Order Sheet' table.
Key Configuration: Operation: Search. Filter: 1 (returns all records).

Code23 (Code n8n node):
Function: Filters the array of all Airtable records, returning only the very last one. This item contains the highest existing serial number (S No) needed for auto-incrementing the new records.

Generating S No1 (Code n8n node):
Function: Takes the S No from the last record found, parses it, increments it by 1, and assigns this new serial number to the current line item being processed. This guarantees a sequential, unique key for the new record.

CustomerSheet (Airtable n8n node):
Function: Final action that writes the cleaned, structured data, complete with allocated costs and the unique serial number, to the Airtable table.
Key Configuration: Operation: Upsert. Matching Column: Order ID (This ensures updates happen if needed, but new records are created based on the unique line-item data.)

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Mohammed Abid
Mohammed Abid

Featured*