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

Use triggers block/unblock the payment request button #1509

Merged

Conversation

helgatheviking
Copy link
Contributor

@helgatheviking helgatheviking commented Mar 27, 2021

Added by @v18:

Please do not merge. This PR is blocked until #1539 is solved. Then it can be merged to trunk. See this comment for more details.


...On a single product page

Changes proposed in this Pull Request:

Use jQuery custom event triggers to block and unblock the payment request buttons

Issue: Link to the GitHub issue this PR addresses (if appropriate).
Fixes #1228

Description:
This is a first step for compatibility with complex product types. For example with Name Your Price, the payment request button should not be clickable until the minimum price is satisfied. With Mix and Match, the payment request button should not be clickable until all the selections are made to fill the container.

Probably still need a way to change the popup error notice to suit the need. Currently, you can get:

Please select some product options before adding this product to your cart.

if the variation isn't selected, but would need a way to supply different notices.

Probably also need a way to pass ALL the form data (and in some cases a custom price). Currently, you are manually adding the data from Addons, but Name Your Price and Mix and Match would have different form data.

Testing instructions

Can test this in the browser's console.

jQuery( document.body ).trigger( 'wc_stripe_block_payment_request_button' );

and

jQuery( document.body ).trigger( 'wc_stripe_unblock_payment_request_button' );

You should see the button go disabled and then be re-enabled. You can also see it happen when a variation is changed or when a product's quantity is changed.


  • Make sure your changes respect WordPress' coding standards.
  • Did you make changes, or create a new .js file? If Gruntfile.js exists in the repo, make sure to run grunt.

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

Code LGTM...

But in addition to disabling the button the "blocked status" also adds a "working/loading indicator". Which makes sense when updating the product quantity for example, but it might be confusing when disabling the button until the user completes other form fields, the user might think they just need to wait

Screen_Shot_2021-04-05_at_17_34_58__3_

@helgatheviking
Copy link
Contributor Author

Not sure I have a solution for that. Any suggestions? I am going on vacation for the weekend and won't be looking at it.

@diegocurbelo
Copy link
Member

diegocurbelo commented Apr 14, 2021

Not sure I have a solution for that. Any suggestions? I am going on vacation for the weekend and won't be looking at it.

We should be able to do both, block/unblock and also disable/enable the Payment Request Button..

I would suggest adding 2 new triggers wc_stripe_disable_payment_request_button and wc_stripe_enable_payment_request_button and two new functions like disablePaymentRequestButton and enablePaymentRequestButton similar to unblockPaymentRequestButton and blockPaymentRequestButton respectively, that add/remove an additional css class that hides the spinner (by hiding .blockUI:before for example)

@v18
Copy link
Contributor

v18 commented Apr 21, 2021

Hi @helgatheviking 👋 - wanted to see if you had any thoughts on the above suggestion. We're all super glad you opened this PR, and I wanted to make sure you had what you needed so we can merge the changes.

@helgatheviking
Copy link
Contributor Author

Hi @v18. Feedback seems sound... I had not noticed the spinners. I am completely overwhelmed with my plugins at the moment and not able to look at this right now.

This is meant to be an opening salvo for #1515 to make this compatible with other marketplace plugins.

@v18
Copy link
Contributor

v18 commented Apr 23, 2021

Thank you @helgatheviking for the update & for your work in this PR so far!

I created a separate issue to update the block UI: #1539

Once that issue is solved (on top of the branch for this PR) and the PR is approved, we'll merged your PR and then merge this fix as well. I updated the PR description to note this so this PR isn't accidentally merged prematurely.

@v18 v18 added pr: ready to merge status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. and removed pr: needs author reply labels Apr 23, 2021
@asumaran
Copy link
Contributor

asumaran commented May 5, 2021

Since the PR that fixes #1539 got approved. I'll be merging this one and then #1542

@asumaran asumaran merged commit 5cb51ff into woocommerce:trunk May 5, 2021
@helgatheviking
Copy link
Contributor Author

Awesome! Thanks so much everyone. Eventually I hope to get a chance to get this integrated into Name Your Price and Mix and Match.

@v18
Copy link
Contributor

v18 commented May 6, 2021

That's awesome @helgatheviking! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: ready to merge status: blocked The issue is blocked from progressing, waiting for another piece of work to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add custom triggers to block/unblock payment request buttons
4 participants