Skip to content

Preselect the first payment option when the buyer holds no choice yet#98

Open
boo-code wants to merge 1 commit into
PrestaShop:mainfrom
boo-code:feat/preselect-first-payment
Open

Preselect the first payment option when the buyer holds no choice yet#98
boo-code wants to merge 1 commit into
PrestaShop:mainfrom
boo-code:feat/preselect-first-payment

Conversation

@boo-code

@boo-code boo-code commented Jul 5, 2026

Copy link
Copy Markdown
Contributor
Questions Answers
Description? On a fresh guest checkout no payment option is selected, so every first-time buyer faces one extra mandatory decision plus a tap, and the "Please select a payment method" stop is reachable at submit. Baymard's payment-selection research (https://baymard.com/blog/payment-method-selection) recommends preselecting the most popular method so "the majority of users can proceed without a deliberate choice". This defaults the selection server-side to the first available payment option when the buyer holds no valid persisted choice: resolvePersistedSelection() falls back to resolveDefaultSelection(), which returns the first option in merchant order (payment modules are ordered by position, so the first option is the shop's preferred method). No client-side change is needed — the template already renders a server-selected option as checked, and the opcPaymentMethodsUpdated listener already confirms it and opens its panel, exactly as for a persisted selection; a buyer's own persisted choice still takes priority, and an invalidated persisted choice now also falls back to the first option instead of an empty selection. Raised in the discussion on #96.
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket?
How to test? vendor/bin/phpunit -c tests/php/phpunit.xml --filter OpcPaymentMethodsHandlerTest (new test: with an empty cookie the response carries the first option's module and selection key; existing persisted-selection test unchanged). On a 9.2 shop, fresh guest checkout: once the address is complete the first payment option renders preselected with its panel open, and the order can be placed without ever clicking the payment list — verified end-to-end (order placed with the preselected method, payment recorded as Bank Wire). Selecting a different option and reloading still restores the buyer's own choice.

@ps-jarvis

Copy link
Copy Markdown
Collaborator

Hello @boo-code!

This is your first pull request on ps_onepagecheckout repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants