Repository navigation
fix: label saved PayPal accounts by account instead of gateway id on block checkout - #4718
Merged
Dinamiko merged 5 commits intoSep 16, 2026
Conversation
The block checkout showed "Saved token for ppcp-gateway" for a saved PayPal or Venmo account. WooCommerce builds that label itself and only reaches its readable form — "<brand> ending in <last4>" — when both fields are present; a wallet has no card number, so it always fell back to the raw gateway id. Pass the account email as last4 to reach the readable branch. The gateway id is not ours to rename: the same value is the payment method slug, so changing it drops the token out of the checkout entirely.
wc_get_credit_card_type_label() lowercases the brand and ucfirst()s whatever it does not recognise, so the My Account payment methods table rendered "Paypal". Register the brand so it keeps its own spelling.
The plugin's wallet token classes extend WC_Payment_Token directly, which the suite had no stub for. Backs the meta and id accessors with instance state so the tokens can be built without WooCommerce loaded.
Covers both filters: the account email reaching last4 for PayPal and Venmo, an absent email leaving last4 alone rather than labelling "PayPal ending in ", Apple Pay and unrelated token types staying as they were, and the brand label being registered without disturbing the existing entries.
Narek13
requested review from
AlexP11223,
Dinamiko,
danieldudzic,
mmaymo and
stracker-phil
as code owners
September 15, 2026 13:51
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. 🔗 Test this pull request with WordPress Playground What's included:
Login credentials:
Plugin Details:
🤖 Auto-generated for commit c712b60 • Last updated: 2026-09-15T14:13:51.042Z |
PHPCS requires a doc comment's long description to open with a capital letter, and this one opened on a function name.
Dinamiko
approved these changes
Sep 16, 2026
Dinamiko
deleted the
dev/PCP-4081-update-pay-pal-token-text-on-blocks-checkout-page
branch
September 16, 2026 10:58
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The block checkout labels a saved PayPal account as "Saved token for ppcp-gateway" — an internal ID, shown to shoppers, in English only.
WooCommerce builds that label itself, in
saved-payment-method-options.tsx:Both branches assume a card. A wallet token has no
last4, so it always falls through to the gateway ID.The ID is not ours to rename. In the same component
method.gatewayis also the payment method slug — it drives thecanMakePaymentfilter, the input name, and the dispatch. Replacing it with a friendly string makes the token fail that check and vanish from the checkout entirely.Changes
last4slot, which is what reaches WooCommerce's readable branch. An absent email leaveslast4unset rather than rendering "PayPal ending in ".branddrops its/ emailsuffix ('PayPal / x@y.com'→'PayPal'), since the email now lives inlast4.paypal => PayPalregistered inwoocommerce_credit_card_type_labels.wc_get_credit_card_type_label()lowercases the brand anducfirsts what it does not recognise, so the account page rendered "Paypal" — it already did before this PR.This is a workaround, not a fix — flagged as such in the code with a
TODO. Feedback is going to Woo separately: tokens need a way to supply their own label, andWC_Payment_Token::get_display_name()already returns the right string for us (PayPal / name@example.com); Blocks just never consults it.Known limits
last4for it, so it still shows the gateway ID.brand && last4branch. WooCommerce 8.2.2 does not: its bundle has only the gateway-ID fallback. Worth confirming against the minimum supported version — on older installs this change is simply inert, not harmful.Backward compatibility
No signature or hook changes. Two behavioural notes:
$item['method']['brand']and['last4']change shape for PayPal and Venmo tokens. Anything readinglast4as four digits gets an email instead — that is the trick, and it is why this is marked temporary.Test steps
Requires a saved PayPal account (vaulting on, pay once with "save" ticked) and a current WooCommerce.
get_display_name(), not this list.