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

[ENHANCEMENT] Add Copy to clipboard suport to discount codes, order ids, payment ids and more. #3217

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

MaximilianoRicoTabo
Copy link
Contributor

@MaximilianoRicoTabo MaximilianoRicoTabo commented Nov 28, 2024

…nstead of open edit page

image image image image image image

All Submissions:

Changes proposed in this Pull Request:

This PR adds small button/icon next to the codes (discount codes, subscripton ids, order id, payment id) and event handlers in the JS admin file to allow users copy to the clipboard those codes.

How to test the changes in this Pull Request:

To test the scenario where the user's browser doesn't have access to clipboard API just start an instance without HTTPS.

To test the happy path scenario just go through different places with buttons and either click to copy and paste it somewhere else. Also it's possible to navigate with tab and copy hitting enter key for accessibility sake.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

@kimcoleman
Copy link
Member

This link isn’t broken as is. It doesn’t open the edit page. It duplicates the discount code as a new code with same settings.

Let’s discuss whether the word copy is misleading and duplicate is better.

@MaximilianoRicoTabo
Copy link
Contributor Author

Should I close this one then @kimcoleman ?

@kimcoleman
Copy link
Member

We can chat about this in a dev meeting. ‘click to copy’ would be nice some other places in the plugin.

@MaximilianoRicoTabo MaximilianoRicoTabo force-pushed the bugfix/copy-discount-code-link branch from 8a98984 to d6110ef Compare December 16, 2024 16:07
* Add button / icon that show / hide on hover / blur and let user copy code to the clipboard
@MaximilianoRicoTabo MaximilianoRicoTabo force-pushed the bugfix/copy-discount-code-link branch from d6110ef to 9b3d31a Compare December 16, 2024 16:10
@dparker1005 dparker1005 added this to the 3.4 milestone Dec 17, 2024
@dparker1005
Copy link
Member

When testing, the ! navigator.clipboard check was failing on my local testing site on both Chrome and Safari. It looks like this may be due to the site not being HTTPS. Maybe we should put up an alert if the copy fails for some reason instead of just returning. Or even better, maybe we should only render the "copy" button if the browser supports copying.

If we're adding this behavior for copying the "discount code" code, maybe we should also add this for copying order codes as well. Or maybe we want a more universal solution that could even be used for payment/subscription IDs.

@MaximilianoRicoTabo
Copy link
Contributor Author

Hey @dparker1005 I took navigator.clipboard support from here -> https://caniuse.com/mdn-api_navigator_clipboard It seems pretty supported to me, but fair enough to hide the button if the browser doesn't support.

Also, we can try a more universal solution, happy to add more effort to this PR to bring functionality to orders and payment / subs ids

…ns from the DOM

* Add further buttons to allow copy to clibboard order ids, subscriptions id, payment and transaction ids.
@MaximilianoRicoTabo MaximilianoRicoTabo force-pushed the bugfix/copy-discount-code-link branch from 02324ef to 4fbc860 Compare December 18, 2024 21:55
@MaximilianoRicoTabo MaximilianoRicoTabo changed the title [BUGFIX] * Copy discount link should copy the code to the clipboard i… [ENHANCEMENT] * Copy discount link should copy the code to the clipboard i… Dec 19, 2024
@MaximilianoRicoTabo MaximilianoRicoTabo changed the title [ENHANCEMENT] * Copy discount link should copy the code to the clipboard i… [ENHANCEMENT] Add Copy to clipboard suport to discount codes, order ids, payment ids and more. Dec 19, 2024
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.

3 participants