Google Pay standalone button
August 12, 2025 · AI Conversations
We have enabled google pay option but I want to display it standlone MEans no required check paypla radio button
By default, the PayPal Payments plugin treats Google Pay as a "PayPal Smart Button" variation, so it only appears inside the PayPal gateway block after the PayPal option is selected.
We can override this behavior with a **template hook** or **JavaScript** to move and display the Google Pay button independently.
—
## **Approach 1: Use the plugin’s shortcode**
The PayPal Payments plugin provides a shortcode that can display the PayPal smart buttons anywhere (including Google Pay if enabled):
<?php
// Place this in a template or via a shortcode handler in functions.php
echo do_shortcode('[paypal_button]');
### To show **only Google Pay**, add a filter:
add_filter( 'woocommerce_paypal_payments_smart_button_params', function( $params ) {
// Disable PayPal & Venmo
$params['style']['layout'] = 'horizontal'; // optional
$params['funding']['disallowed'] = [ 'paypal', 'venmo', 'card' ];
// Allow only Google Pay
$params['funding']['allowed'] = [ 'googlepay' ];
return $params;
});
This will make the shortcode render **Google Pay only**, and you can place it **above or outside** the payment methods list.
—
## **Approach 2: Move Google Pay button with JS**
If the plugin doesn’t allow filtering by funding source easily, you can **move the rendered Google Pay button** to another place using JavaScript:
jQuery(function($) {
var observer = new MutationObserver(function() {
var gpayBtn = $('.paypal-buttons [data-funding-source="googlepay"]');
if (gpayBtn.length && !$('#standalone-gpay').length) {
gpayBtn.clone(true).attr('id', 'standalone-gpay').insertBefore('.woocommerce-checkout-payment');
}
});
observer.observe(document.body, { childList: true, subtree: true });
});
This **copies** the Google Pay button outside the PayPal payment method section so users don’t need to click PayPal first.
—
## **Approach 3: Use Express Checkout Mode**
In **WooCommerce → PayPal Payments → Standard Payments → Smart Buttons**, there’s a setting for **"Show buttons on product/cart pages"**.
If enabled and restricted to only Google Pay via the filter above, you can show the standalone Google Pay button on the cart or checkout without the PayPal gateway being selected.
—
If you want, I can give you **ready-to-use code** that makes Google Pay show **above the payment methods list** on the checkout page and work without selecting PayPal at all.
That would make it look like a completely separate payment option.
Yes and but don't remove default paypal selection
I’ll give you a snippet that **adds a standalone Google Pay button above the payment methods list**, but still keeps the **normal PayPal option** in the checkout.
This uses the **PayPal Payments plugin’s built-in Smart Button rendering** but restricts it to only show Google Pay for this extra button.
—
### **functions.php**
// Add a standalone Google Pay button above payment methods
add_action( 'woocommerce_review_order_before_payment', 'add_standalone_gpay_button', 5 );
function add_standalone_gpay_button() {
?>
<div id="standalone-gpay-wrapper" style="margin-bottom:20px;">
<h3>Pay instantly with Google Pay</h3>
<div id="standalone-gpay"></div>
</div>
<script type="text/javascript">
jQuery(function($){
// Wait for PayPal SDK to load
function renderStandaloneGpay() {
if (typeof paypal === 'undefined') {
setTimeout(renderStandaloneGpay, 300);
return;
}
// Render Google Pay only
paypal.Buttons({
fundingSource: paypal.FUNDING.GOOGLEPAY,
style: {
layout: 'horizontal',
height: 45
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: wc_checkout_params.cart_total
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Redirect after success
window.location.href = wc_checkout_params.checkout_url;
});
}
}).render('#standalone-gpay');
}
renderStandaloneGpay();
});
</script>
<?php
}
—
### **What this does**
– Adds a **"Pay instantly with Google Pay"** section **above the payment methods**.
– Uses the **PayPal SDK’s funding filter** so **only Google Pay** appears there.
– Keeps the normal **PayPal method & buttons** in the checkout.
– Works without requiring the PayPal radio button to be selected.
—
If you want, I can make this **integrate fully with WooCommerce checkout** so clicking the standalone Google Pay actually **submits the order** and skips the PayPal selection step.
That way it behaves exactly like a normal payment method but stays standalone.
Do you want me to make that version?