Payment form JS isn't loaded at checkout for free orders
When an order starts out as free at checkout, core doesn't render the payment methods UI. If the customer updates checkout, like choosing a new shipping method and $$$ needs to be charged, core refreshes checkout and ends up rendering the our gateway payment fields.
However, the way we enqueue the payment form JS handler means it'll only be present on initial page load, and not come along with any AJAX refreshes.
We'll need to change how we enqueue the JS so that it's present in the payment method form UI itself, or figure out some other way to load it on refresh.
- Report from: HS convo 94602 would like for the JavaScript to not show up on all their pages.
Hi @ChaseWiseman. I just happened to post https://wordpress.org/support/topic/2-2-0-please-stop-enqueuing-payment-javascript-sitewide/ yesterday.
Your issue description here sounds like it could be related to my concerns, and perhaps could be addressed with this re-arrangement work. Wdyt?
EDIT traced my issue to https://github.com/skyverge/wc-plugin-framework/blob/master/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php#L354
@lkraav yep I think this would be a good place to look at that as well.
One thing about some of these more modern gateways is that they will need to enqueue their scripts on more and more pages outside of checkout as we add things like Apple Pay and express checkout (via PayPal in Braintree's case) since those are to be made available on the single product pages, cart, and even archive pages in the future.
But it's still good to keep these concerns in mind and limit things where we can!
One thing about some of these more modern gateways is that they will need to enqueue their scripts on more and more pages
I would love to have a say in the "maybe" decision via add_filter()