Preselect the first payment option when the buyer holds no choice yet#98
Open
boo-code wants to merge 1 commit into
Open
Preselect the first payment option when the buyer holds no choice yet#98boo-code wants to merge 1 commit into
boo-code wants to merge 1 commit into
Conversation
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! |
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.
resolvePersistedSelection()falls back toresolveDefaultSelection(), 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 theopcPaymentMethodsUpdatedlistener 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.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.