Accentuate Custom Fields
  • Welcome!
  • Introduction
    • Getting started with ACF
    • Field scopes
    • How to show fields in your storefront
  • Dashboard
    • Reference Manager
      • Creating a new reference within Reference Manager
    • Filter & Group
      • Filter editor
      • Filter usage
    • Activity log
    • App settings
  • Field Definitions
    • Fields & Sections
    • Deciding on a field type
    • ACF Field types
      • Text
      • Markdown text
      • HTML
      • Checkbox
      • Selection
      • Tags
      • Number
      • Date
      • Color
      • Media v1 (legacy)
      • Media v2
      • Custom Object (JSON)
      • Multi-language Text
      • Reference fields
      • References to Global fields
    • Shopify Field types
      • Shopify » Single line text
      • Shopify » Multi-line text
      • Shopify » Boolean
      • Shopify » Color
      • Shopify » Custom objects (JSON)
      • Shopify » URL
      • Shopify » Date
      • Shopify » Date and Time
      • Shopify » Integer
      • Shopify » Decimal
      • Shopify » Weight
      • Shopify » Volume
      • Shopify » Dimensions
      • Shopify » Reference fields
    • Automatic tagging
    • Large sets
    • Field contexts
    • Field context filters
    • Copy and paste fields
    • Change field name and type
    • Import existing fields
    • Linking multiple stores
  • The Editor
    • Using the editor
    • Promote fields to sidebar
    • Layouts
    • Hide from search
    • Repeatable fields
    • Version control
    • Update value on order creation
  • Bulk Import & Export
    • Export custom field values
    • Import custom field values
    • Metaobject export / import
  • METAOBJECTS
    • What are Metaobjects?
    • Metaobject Definitions
    • Metaobject instances / values
    • Displaying Metaobjects on your storefront
    • Metaobject export / import
  • THEME EXTENSIONS
    • SEO keywords
    • Sticky promo bar
    • Products promotion
  • Liquid Guides
    • Learning Liquid
    • Resize & crop images
    • Check for empty values
    • Access field definitions
    • Order notifications
    • Allow customers to change their field values
  • OTHER
    • Webhooks
    • API
      • Access to custom fields
      • Endpoints
  • Help
    • FAQ
      • Why are one of my products no longer showing in my reference field?
      • I have multiple products/variants with the same name
      • How do I make changes to my field values in bulk?
      • I added a new field definition but it is not showing in my storefront
      • How do I copy my field setup to another store?
      • My fields are still showing after I have deleted their field definition
      • Why are none of my fields showing in the editor?
      • My newly created object in Shopify is not available in ACF
      • Reference lists are empty?
      • Why am I seeing a "value cannot exceed 100,000 characters" error when saving?
      • Why can't I name my field "first", "last" or "size"?
    • Need help?
  • Product
    • Changelog
    • Feedback & Suggestions
Powered by GitBook
On this page
  • How to link cart attributes with ACF fields
  • Example
  1. The Editor

Update value on order creation

PreviousVersion controlNextExport custom field values

Last updated 10 months ago

Using ACF, you can define custom fields for orders, that automatically get updated on order creation. This is useful when a customer provides values for an order, that you need to handle in a structured way after the fact, like including the information in your order notifications, invoices or in the customer's order overview. Examples include purchase order references, special delivery instructions, "how did you hear about us" dropdowns or any other information that doesn't fit neatly into the default "order note" field, that is available for a Shopify order. Collecting these types of values from the customer in the cart is supported by Shopify via the concept of "cart attributes", which is documented in . However, ACF takes this concept a step further and can pull the provided information from the order's attributes into separate custom fields defined by you, so you can handle them more elegantly like showing the provided values on a customer's order overview.

Due to the fact that Shopify handles cart attributes as pure text, the integration is currently not possible for files

How to link cart attributes with ACF fields

For every field, you'd like to have updated from the order via a cart attribute value, you need to enable this checkbox in the field definition:

Once saved, ACF will listen to new orders being created and look at the incoming order's list of provided cart attributes, and compare these with any defined fields with the checkbox "Set value automatically when order is placed" checked.

Example

You have an order custom field defined like this:

And have this set:

And this field definition is part of your cart's form:

<input name="attributes[Purchase Order Reference]" type="text" ....>

Then ACF will match the cart attribute named "Purchase Order Reference" with your defined fields and update the custom field's value with whatever value was provided via the order. Matching a cart attribute with a custom field is done by looking at the "name" provided in your cart attribute fields and comparing it to your custom fields' label. In case you're wondering, this is done without looking at upper-/lower cases, so feel free to mix as you please. You can also use the field's name as the cart attribute name if this suits you better, so this approach also links the attribute with the custom field:

<input name="attributes[purchase_order_reference]" type="text" ....>

If you need to pass multiple values to a repeatable custom field, i.e. transferring an array of values, you need to define a form "array" (note the closing [ ]'s):

<select multiple name="attributes[preferred_color][]">
  <option value="Magenta">Magenta color</option>
  <option value="Plum">Plum color</option>
  <option value="Beige">Beige color</option>
</select>

If you need to pass a value to a multi-language custom field, you need to make sure the submitted value is a stringified JSON-object with the desired ISO code (language) as the key:

{ "en": "This is the submitted value in English" }

You can use the to define your cart attributes

Shopify UI Elements Generator
this help article