-
Notifications
You must be signed in to change notification settings - Fork 211
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
Use triggers block/unblock the payment request button #1509
Conversation
c90a3f9
to
ff39439
Compare
There was a problem hiding this 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
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, I would suggest adding 2 new triggers |
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. |
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. |
Awesome! Thanks so much everyone. Eventually I hope to get a chance to get this integrated into Name Your Price and Mix and Match. |
That's awesome @helgatheviking! Thank you :) |
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:
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.
grunt
.