Created
May 6, 2026 06:38
-
-
Save xlplugins/b45838e30ba7db6ff6d7d4168d3b9ba7 to your computer and use it in GitHub Desktop.
express as inline in payment method list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * FunnelKit Stripe — render inline Google Pay / Apple Pay buttons inside the | |
| * payment-method <li> instead of beside the WooCommerce Place Order button. | |
| * | |
| * Drop into a child theme's functions.php, an mu-plugin file, or Code Snippets. | |
| */ | |
| add_action( 'fkwcs_stripe_apple_pay_after_payment_field_checkout', static function () { | |
| echo '<div class="fkwcs_stripe_apple_pay_button fkwcs-inline-relocated"></div>'; | |
| } ); | |
| /** | |
| * Google Pay + CSS hiding for outside-<li> Apple Pay wrapper. | |
| */ | |
| add_action( 'wp_footer', static function () { | |
| if ( ! function_exists( 'is_checkout' ) || ! is_checkout() ) { | |
| return; | |
| } | |
| ?> | |
| <style> | |
| /* Hide every wallet wrapper that isn't the in-<li> one we control */ | |
| .fkwcs-gpay-button-container:not(.fkwcs-inline-relocated), | |
| .fkwcs_stripe_apple_pay_button:not(.fkwcs-inline-relocated) { | |
| display: none !important; | |
| } | |
| /* Spacing inside the payment-method <li> */ | |
| li.payment_method_fkwcs_stripe_google_pay .fkwcs_google_pay_button:not(:empty), | |
| li.payment_method_fkwcs_stripe_apple_pay .fkwcs_stripe_apple_pay_button.fkwcs-inline-relocated { | |
| margin-top: 10px; | |
| } | |
| </style> | |
| <script> | |
| (function ($) { | |
| if ( typeof $ === 'undefined' ) { return; } | |
| var GPAY_LI = 'li.payment_method_fkwcs_stripe_google_pay'; | |
| /** | |
| * Google Pay: the plugin creates the button in JS via | |
| * $('#place_order').after(this.gpay_button_html); | |
| * (stripe-elements.js, FKWCS_GOOGLEPAY.createGpayButton). | |
| * We move it into the empty .fkwcs_google_pay_button slot rendered | |
| * inside the <li> by parts/google_pay.php. | |
| */ | |
| function moveGpay() { | |
| var $btn = $('.fkwcs-gpay-button-container').not(GPAY_LI + ' *').first(); | |
| if ( ! $btn.length ) { return; } | |
| var $slot = $(GPAY_LI + ' .fkwcs_google_pay_button').first(); | |
| if ( ! $slot.length ) { return; } | |
| $slot.empty().append( $btn.addClass('fkwcs-inline-relocated') ); | |
| } | |
| $( document.body ).on( | |
| 'updated_checkout payment_method_selected fkwcs_smart_buttons_showed', | |
| function () { | |
| setTimeout( moveGpay, 30 ); | |
| setTimeout( moveGpay, 350 ); | |
| } | |
| ); | |
| $(function () { | |
| setTimeout( moveGpay, 600 ); | |
| setTimeout( moveGpay, 1800 ); | |
| }); | |
| })( window.jQuery ); | |
| </script> | |
| <?php | |
| }, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment