Ryan, we have somewhat quietly released writable customer metafields in our app Metafields2 and it has been working well for a few initial shops. It requires some front-end development savvy, not a plug and play for just anyone, but if you have the capability it is definitely doable. Below are more details, instruction, and some example code...
Below is a snippet of liquid, html, and jQuery that you could place inside a customer accounts template, illustrating a simple form to save customer metafield values using the app’s special URL path in your store...
<!-- sineLABS example snippet, writable customer metafields. Replace example metafield inputs with your actual metafields. //--><div><form action="/a/custmeta" method="POST" id="custmeta"> <input type="hidden" name="customer[id]" value="{{ customer.id }}" /><input type="text" name=“metafield[namespace1.key1]" value="{{ customer.metafields.namespace1.key1 }}" placeholder=“namespace1.key1" /><input type="text" name=“metafield[namespace2.key2]" value="{{ customer.metafields.namespace2.key2 }}" placeholder=“namespace2.key2" /><input type="submit" /></form><script> $('form#custmeta').submit(function(e) { e.preventDefault(); $.ajax({ type: "POST", dataType: "json", data: $(this).serialize(), url: $(this).attr('action'), success: function (data) { var formValid = (data.status === 'OK'); if (formValid) { var msgs = ''; for (var i=0;i<data.messages.length;i++) { msgs += '-- ' + data.messages[i] + '\n'; } if (msgs > '') { alert('SUCCESS WITH MESSAGES:\n\n' + msgs); } else { alert('SUCCESS!'); } } else { alert('Status: ' + data.status + '\nMessage: ' + data.message); } }, error: function (jqXHR, textStatus, errorThrown) { alert('AJAX or Server 500 error occurred'); } }); return false; });</script></div><!-- End of sineLABS example //-->
Some notes:
- The customer must exist and have an ID to write to their respective metafields. You could still put the fields on the customer account registration form, but you’d need to temporarily persist the values to cookie, or local/session storage in the browser and when the new customer account form has returned success with the customer ID available, send off the call to /a/custmeta with the values.
- If a customer is newly registered/created and doesn’t exist yet in the metafields2 app resource list, the app will go looking for the new customer id and sync it quickly into the metafields app before saving metafield values
- Metafields of integer type will return an error message if value is anything other than convertible to integer.
- Metafields must be already configured in the app dashboard before they can be written to using this method.
This should get you going. Feel free to let us know when you’re able to dive in and if we can answer any other questions at support-AT-sinelabs-DOT-com. Good luck!