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

Validate and present custom error for not in allowed emails coupons #43872

Merged

Conversation

wavvves
Copy link
Contributor

@wavvves wavvves commented Jan 22, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR introduces upfront validation in allowed emails coupons, opposed to the current procedure of adding the coupons and removing them when placing the Order if the billing email does not match the coupon whitelist of emails.
It also updates the error messages presented to the user, stating clearly why the coupon was not accepted and how to proceed to use it effectively.

Cart Checkout
Blocks image image
Shortcode image image

Closes #26289
Closes #26305

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Prior to testing

  1. Create four pages with Shortcode Cart, Shortcode Checkout, Blocks Cart and Blocks Checkout
  2. In WC Settings, set the Cart page to the Shortcode Cart page you created (we need this to avoid the bug reported here Classic Cart fails to render after applying coupons when it is not set as the default Cart page #44232 )
  3. Go to Marketing > Coupons
  4. Create a new coupon restricted to the email allow@yay.com (make sure this email is not associated with your account), with any discount amount
  5. Create another coupon named "test" without restrictions, with any discount amount
  6. Add some items to your cart.

Shortcode Cart Test

  1. Go to the shortcode cart page
  2. Apply the coupon "test" and verify it gets applied and the totals update
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error notice is displayed

Blocks Cart test

  1. Go to the Blocks Cart page
  2. Apply the coupon "test" and verify it gets applied and the totals update
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error is displayed

Shortcode Checkout test

  1. Go to the shortcode Checkout page
  2. Fill the email field to something else than "allow@yay.com"
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error notice is displayed
  4. Change the email field to "allow@yay.com"
  5. Apply the restricted coupon and verify it gets applied correctly
  6. Place the order and verify applied discounts were effective

Blocks Checkout test

  1. Go to the Blocks Checkout page
  2. Fill the email field to something else than "allow@yay.com"
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error is displayed
  4. Change the email field to "allow@yay.com"
  5. Apply the restricted coupon and verify it gets applied correctly
  6. Place the order and verify applied discounts were effective

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@wavvves wavvves linked an issue Jan 22, 2024 that may be closed by this pull request
3 tasks
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 22, 2024
Copy link
Contributor

github-actions bot commented Jan 22, 2024

Test Results Summary

Commit SHA: 018c790

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 39s
E2E Tests780028003587m 6s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@wavvves wavvves self-assigned this Jan 31, 2024
@wavvves wavvves changed the title Deny and present custom error message for not in allowed emails coupons Present custom error message for not in allowed emails coupons Jan 31, 2024
@wavvves wavvves changed the title Present custom error message for not in allowed emails coupons Present custom notice for not in allowed emails coupons Jan 31, 2024
@wavvves wavvves changed the title Present custom notice for not in allowed emails coupons Validate and present custom error for not in allowed emails coupons Feb 2, 2024
@wavvves wavvves requested a review from nielslange March 12, 2024 17:47
@wavvves wavvves marked this pull request as ready for review March 12, 2024 17:48
@woocommercebot woocommercebot requested a review from a team March 12, 2024 17:50
Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @wavvves. While reviewing it, I noticed the cart-related error message on the checkout shortcode page. I left a comment for that. Apart from that, the PR is working as expected. I just mentioned a few nitpicks to potentially improve the readability, and I left a comment regarding extending the test cases to cover all affected pages (cart and checkout blocks and shortcodes).

@nielslange nielslange self-requested a review March 19, 2024 13:29
Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

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

I've successfully tested this PR, @wavvves. Thanks for this improvement. 🙌

@wavvves wavvves merged commit 0a3cf74 into trunk Mar 20, 2024
63 of 64 checks passed
@wavvves wavvves deleted the enhancement/26289-coupons-allowed-emails-dont-work-as-expected branch March 20, 2024 10:19
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 20, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 20, 2024
@Stojdza Stojdza added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: coupon Issues related to coupons. focus: e2e tests Issues related to e2e tests needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Rubik
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coupon current user validation Coupons -> Allowed Emails don't work as expected
9 participants