Common pitfalls
Mutating elements within a form
It’s a common use-case to change elements within a form built in Customer Fields. There are some things you need to watch out for – one wrong step can cause the form to crash. Avoid deleting, moving or adding elements programmatically. Prefer CSS display: none
or order: <number>
.
Too many calls to CF.customer.save
You can run into Shopify’s rate-limiting if you make too many calls to CF.customer.save
. If you want to auto-save in order to avoid data loss, try an approach that hooks into the beforeunload
to catch the tab closing and/or blur
to detect when the window has lost focus.
You could also try storing the form payload in localStorage
if that works for your use-case. No rate limiting to worry about there!