Shopify Checkout Extensibility is fantastic, but there are key issues with handling custom order data like tax IDs. This RFC highlights two main problems: the inability to validate metafields in server-side functions and performance issues with order attributes. Fixing these will improve data integrity and order accuracy for merchants.
The Problem
Let’s say you’re building a checkout extension that collects additional information, such as a tax ID. You need to store this data somewhere, and Shopify gives you two main options:
- Metafields: These are the modern, recommended way to store custom data.
- Order Attributes: An older method, but still widely used.
You choose metafields because it’s 2024 Everything works smoothly at first - you can save the tax ID and even refresh the checkout to confirm that the data is still there. But soon, you’re tasked with validating the tax ID to match a specific format. Here’s where the problem starts.
To perform secure validation, you naturally turn to Shopify’s server-side validation functions. They are ideal for ensuring that only properly formatted data gets passed through to the final order. But—you can’t access metafields within these validation functions. This severely limits your ability to enforce data integrity when using metafields, which is supposed to be the modern solution.
So, you’re forced to switch to order attributes, because they can be read by the server-side functions. But this brings along two new problems:
- Performance Issues: Saving order attributes is much slower compared to metafields. Every time the user interacts with the field - it takes around one second to save the changes, whereas metafields are nearly instant.
- Inability to Delete Attributes: Once you’ve added an order attribute, you can’t remove it—you can only set it to an empty string. This creates issues when, for example, a buyer decides to remove their tax ID. An empty attribute could confuse downstream systems expecting either valid data or no data at all, not an empty string.
What Needs to Change
To solve these issues and improve custom data handling in Shopify checkout, I suggest the following changes:
-
Allow access to metafields in validation functions: Developers need to be able to validate data stored in metafields directly within Shopify’s validation functions. This would eliminate the need for insecure client-side validation and improve overall data integrity.
-
Improve order attribute performance: Order attributes should save as quickly as metafields to avoid checkout delays. Slower save times negatively affect the user experience and increase the likelihood of errors.
-
Allow deletion of order attributes: Instead of setting attributes to an empty string, allow developers to fully remove them. This would prevent empty fields from causing problems in downstream systems.
Conclusion
These issues—metafield validation, order attribute performance, and the inability to delete attributes—can result in inaccurate data being passed into orders, causing problems for merchants and downstream systems. Addressing these gaps will improve data integrity and ensure smoother operations for merchants relying on accurate order information.