Skip to content
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

Add payment icons to multiple UPE #4860

Merged

Conversation

bborman22
Copy link
Contributor

@bborman22 bborman22 commented Oct 7, 2022

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

  • Checkout the current branch which was branched off of the multiple UPE branch
  • Change currency to EUR to allow the relevant payment methods in UPE
  • Set up an account and enable UPE
  • Enable all relevant payment methods in UPE
  • As a customer add item to cart and go to checkout
  • Should see icons next to the payment methods as pictured below

UPE-payment-icons

  • Disable UPE and check for CC icons still displayed

CC-payment-icons


  • Run npm run changelog to add a changelog file, choose patch 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.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@bborman22 bborman22 requested review from a team, tommyshellberg and brettshumaker and removed request for a team and tommyshellberg October 7, 2022 19:14
Copy link
Contributor

@brettshumaker brettshumaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as expected for me. 🎉

The approach of defining the icons within the payment method classes makes sense to me.

@bborman22 bborman22 merged commit 88be4a9 into poc/upe-instances-multiplied Oct 13, 2022
@bborman22 bborman22 deleted the add/4666-multi-upe-payment-icons branch October 13, 2022 13:18
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