Is it possible for Checkout UI useAppMetafields to access multiple metafields when there are multiple of the same functions?
Example:
On admin, set up multiple discount rules for the same function (with different codes)
On checkout, the Checkout UI useAppMetafields appears only have access to the latest saved function discount rule. The earlier saved config rules are not visible.
When you define metafields in the shopify.ui.extension.toml configuration file, your extension can access these metafields. However, each pair of namespace and key should be unique. If you define multiple metafields with the same namespace and key, only the latest one will be accessible.
In your case, if you have different discount rules, you could consider using different keys for each of them. For example:
Remember that the fields in the metafields array in the shopify.ui.extension.toml configuration file should correspond to the actual metafields that exist in your Shopify store admin.
To be clear, the issue is with multiple of the SAME discount rule.
This is when an admin goes in and create discount#1 (of function #1), then creates another discount #2 (of the same function #2) with a slightly different condition (like different coupon codes).
When a customer adds a discount code we want to gift them a free product.
We can add the product with a checkout extension UI component. This is not a problem.
However, we need to be able to access the discount configuration from the function metafield so we know what product to add.