Skip to content

Prevent early is_enabled() check for Google Pay button in new UI (5021) #3566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

Narek13
Copy link
Collaborator

@Narek13 Narek13 commented Jul 29, 2025

Issue Description

  1. When Google Pay isn't selected in Styling->Products location then it will not be visible in Store -> Mini cart, as well. Despite the fact that, for mini cart location Google Pay will be selected.
  2. When in Styling → Mini cart location "Enable payment methods in this location" will not be checked, then Google Pay will not be available for Store : Block cart, Express checkout, Product page.

The Problem

In the old UI, we don’t have location-based settings for the Google Pay button. Instead, we rely on a single setting — googlepay_button_enabled — to enable or disable the button globally across all locations.

In the new UI, however, we support location-based settings, and we map the googlepay_button_enabled option individually for each location.

The issue arises because, during block registration, we call $button->is_enabled(). This method uses ContextTrait to determine the current context. But inside the woocommerce_blocks_payment_method_type_registration hook, context-detection functions like is_cart() always return false , because this hook is triggered too early in the WordPress lifecycle, before those context functions are properly initialized.

As a result, the context defaults to 'mini-cart', which is typically disabled by default. This leads to $button->is_enabled() returning false, and the Google Pay payment method is not registered in the block cart.

PR Description

This PR prevents early is_enabled() check for Google Pay button in new UI.
In the new UI, the Google Pay button availability is determined by gateway enablement and location selection, not a global setting. The is_enabled() check depends on context functions (like is_cart()), which return false too early during block registration.

In the new UI, the Google Pay button availability is determined by gateway enablement and location selection, not a global setting. The `is_enabled()` check depends on context functions (like `is_cart()`), which return `false` too early during block registration.

This commit skips the `is_enabled()` check when the new UI is active to avoid incorrect context evaluation and ensure the Google Pay button is properly registered.
@Narek13 Narek13 self-assigned this Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants