Skip to content

Conversation

kidunot89
Copy link
Collaborator

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix/devops branch (right side). Don't pull request from your master!
  • Have you ensured/updated that CLI tests to extend coverage to any new logic. Learn how to modify the tests here.

What does this implement/fix? Explain your changes.

Fix checkout mutation notices handling (Issue #666)

Problem: The checkout mutation wasn't exposing WooCommerce session notices, causing them to persist across requests and preventing clients from receiving payment gateway error messages.

Solution:

  • Added notices field to checkout mutation output with new CartNotice and CartNoticeTypeEnum GraphQL types
  • Enhanced error handling to capture WC notices in catch blocks and include them in error messages
  • Ensured notices are properly cleared from session to prevent persistence
  • Updated test expectations for WooCommerce error message format changes

Changes:

  • includes/mutation/class-checkout.php: Enhanced mutation with notice handling
  • includes/type/enum/class-cart-notice-type.php: New enum for notice types
  • includes/type/object/class-cart-notice.php: New GraphQL object for notices
  • includes/class-type-registry.php: Registered new types
  • includes/class-wp-graphql-woocommerce.php: Added type imports
  • tests/wpunit/CheckoutNoticesTest.php: Comprehensive test suite
  • tests/wpunit/CartMutationsTest.php: Fixed failing test with updated error message

Testing: All 5 new checkout notice tests pass, plus fixed existing cart mutation test.

Does this close any currently open issues?

Fixes #666

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

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.

Checkout mutation does not return WC Session Notices
1 participant