Skip to content

Conversation

@AlexP11223
Copy link
Contributor

@AlexP11223 AlexP11223 commented Oct 26, 2022

All Submissions:

Changes proposed in this Pull Request:

During checkout validation, there are points where we specifically rely on various $_POST superglobal values being set, which made reuse of our validation functionality difficult. This change tidies this up.

Closes #35328.

How to test the changes in this Pull Request:

Checkout validation should continue to work as it did previously. More specifically, we should ensure that we are still validating if the custom has agreed to the shop's terms and conditions (since the change touches that check):

  1. Ensure you have designated a terms and conditions page (via WooCommerce ▸ Settings ▸ Advanced ▸ Page Setup):

terms-and-conditions

  1. As a customer, add a product to your cart and attempt to checkout. In the first instance, populate the checkout form correctly but avoid checking the box that indicates you agree with the terms and conditions:

  1. Consequently, on trying to checkout, you should see a warning as follows:

tc-error

  1. Rinse and repeat; except agree to the terms and conditions. If all other fields are correctly populated, you should be able to checkout successfully.
  2. Repeat again, but try to supply invalid values to other checkout fields (for example, you might provide an invalid postal code) and confirm validation successfully prevents this.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution labels Oct 26, 2022
@woocommercebot woocommercebot requested review from a team and barryhughes and removed request for a team October 26, 2022 07:34
barryhughes
barryhughes previously approved these changes Oct 26, 2022
Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! We can merge once checks pass (unfortunately, a glitch meant our coding standards check was initially failing for reasons unrelated to your change).

@barryhughes
Copy link
Member

Hitting pause on this review (internal convo: p1666827490378459-slack-C03CPM3UXDJ).

It seems that to unblock the required check we will ultimately need to document all the currently undocumented hooks, though they are otherwise nothing to do with the core change this PR was raised to address (and I'm reluctant to push placeholder text to satisfy the linter, since that defeats the purpose).

AlexP11223 and others added 4 commits November 17, 2022 11:59
…heck.

This does not address all of the undocumented hooks (there are many in this file), just the ones flagged by the GitHub Actions code sniff check. This is an effort to unblock the PR, which we otherwise cannot merge at present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: validate_checkout uses $_POST directly

2 participants