Add payment icons to multiple UPE #4860
Merged
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.
Fixes #4666
Changes proposed in this Pull Request
Add Payment Icons to UPE Payment Methods
This PR adds an icon attribute to the UPE and CC payment methods that will be displayed at checkout. I opted to add the icon URL to the payment methods themselves rather than at the abstract class and derive the image based on the method name as it seemed a lot clearer to define all of the payment method specific items within the payment method classes. This also allows more flexibility between icon file names and payment method names. I could easily be convinced to change the approach though.
The implementation also takes advantage of the WooCommerce built in icon handling by just setting the icon attribute on the gateways. The relevant WooCommerce code can be found in these two spots if you wanted to review how the icons are used in WC:
https://github.com/woocommerce/woocommerce/blob/1eb02b4742d685b596ef518affe44637bf9cfb26/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php#L326
https://github.com/woocommerce/woocommerce/blob/1eb02b4742d685b596ef518affe44637bf9cfb26/plugins/woocommerce/templates/checkout/payment-method.php#L26
I made these changes off of the multiple UPE POC branch as that was the only way to display the icons for all payment methods at checkout. Let me know if this should be rebased off of develop though before merging. This current arrangement just makes testing easier.
Testing instructions
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge