Update value on order creation

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 this help article. 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

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-/lowercases, 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" ....>

You can use the Shopify UI Elements Generator to define your cart attributes

If you need to pass multiple values to a repeatable custom field, i.e. transferring an array of values, you need 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" }

Last updated