We use custom cart attributes for one of my clients. They’re very important. We found out that if a customer uses Apple Pay, Google Pay, or Shop Pay, the cart attributes do not come through at all.
The problem is that when users click on one of those quick payment buttons, the cart form is not submitted like if they clicked on the standard Check Out button.
That means if the user fills out or edits the custom cart attributes, they were never saved first.
The “order notes” come through fine, because if you watch carefully, any changes to that field triggers a form submit action (you can see the page update as soon as you leave that field).
The solution, we found, is to mimmic the order notes field and trigger a form update whenever the custom cart attributes change, like this:
That leaves one more problem. If the user does not change any of your custom cart attributes, then our form.submit() is not issued. This might be a problem if you depend on the default custom cart attributes and their respective default values to be added to the order. To get those default custom cart attributes to always come through, we add this JS hack to cart-template.liquid which I’m not too crazy about but it works:
{%- if cart.attributes["My-Custom-Cart-Attribute-1"] == blank -%}
{%- endif -%}
The idea is that if the custom form attribute has not been set, then submit the form right away on page load so they are registered. USE THIS WITH CAUTION and test or you might suffer an infinite loop.
I hope Shopify fixes the problem with the quick-pay buttons - the form should be submitted first those button are clicked to register those custom cart attributes. Looks like they knew about the problem so they force the order notes to save on change. But that seems to be a dirty / unfinished fix.
Gary