Skip to content

How to fetch product details purchased by customers in workflows

The Pluck and Join feature in Stack workflows allows you to dynamically pull product details, such as titles, from order submissions and format them into a single string. This is particularly useful for automating order management, syncing product information with external systems, or updating data logs like Google Sheets. You can use Pluck and Join just like any custom field to format your data efficiently.

With this feature, you can fetch product details, such as items from submitted orders, and send this data to platforms like Google Sheets or others.

The Pluck and Join feature enables you to use helpers like pluck and join in workflows:

  • Pluck: Extracts specific fields (e.g., product titles) from an array of objects.
  • Join: Combines these values into a single string with a custom separator.

These tools are invaluable for automating data extraction and formatting across various datasets.

Start by setting up a workflow trigger, such as Order Form Submitted or Inbound Webhook, to initiate the workflow when an order is placed.

For example, you can use the Create Row in Google Sheets action to log customer and product details:

  • Customer Name: Use {{ contact.first_name }}
  • Email: Use {{ contact.email }}
  • Products: Use the combined string created in the next step
  1. Pluck: Use the pluck helper to extract product titles from the order’s line_items array.

    `{{ pluck order.line_items "title" }}`
  2. Join: Combine these titles into a single, formatted string.

    `{{ join (pluck order.line_items "title") ", " }}`

Before finalizing, run a test to ensure the workflow processes data as expected. Use tools like Postman or live order submissions to confirm the correct output.

Imagine you want to log order details into a Google Sheet whenever a customer submits an order form. This log should include the customer’s name, email, and a formatted list of purchased products.

  1. Create Workflow Trigger: Use the Order Form Submitted trigger to start the workflow.

  2. Use Pluck and Join Helpers:

    • Extract product titles using the pluck helper:

      `{{ pluck order.line_items "title" }}`
    • Format the titles using the join helper:

      `{{ join (pluck order.line_items "title") ", " }}`
  3. Add Google Sheets Action: Select the Create Row in Google Sheets action and map the fields:

    • Name: {{ contact.first_name }}
    • Email: {{ contact.email }}
    • Products: {{ join (pluck order.line_items "title") ", " }}
  4. Test and Activate the Workflow: Submit a test order form and confirm that the order details appear correctly in the Google Sheet.

Name Email Products
Alice alice@test.com TEST OFFER, ANOTHER PRODUCT
Bob bob@test.com SINGLE ITEM

By using pluck and join helpers, you can efficiently extract and format product data for seamless workflow automation and integration. This feature saves time, reduces manual effort, and enhances the usability of your workflows.

Can't find what you need? Call or text +1 787 665-9212 or email support@stackapp.co.© Stack · Privacy · Terms