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

Fix fatal error when editing the shortcode checkout page #3758

Merged
merged 5 commits into from
Jan 24, 2025

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Jan 22, 2025

Fixes #3757

Changes proposed in this Pull Request:

This PR fixes a fatal error thrown when editing the shortcode checkout page on PHP 8.4 with an empty cart:

PHP Fatal error: Uncaught Error: Call to a member function needs_shipping() on null in */wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-express-checkout-helper.php:629

The fix consists on checking the existence of the cart object before calling the needs_shipping method.

Testing instructions

Code review should be enough. If you want to test it:

  • Checkout and build this branch on your test environment (fix/fatal-error-editing-shortcode-checkout)
  • Make sure you are running your store on PHP 8.4
  • As a merchant, edit your shortcode checkout page (create one before if you don't have it)
  • Confirm no fatal errors are thrown

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@wjrosa wjrosa self-assigned this Jan 22, 2025
@wjrosa wjrosa marked this pull request as ready for review January 22, 2025 12:35
@wjrosa wjrosa requested a review from diegocurbelo January 22, 2025 12:42
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.

Thanks for fixing this @wjrosa!

LGTM 🚢

@wjrosa wjrosa merged commit 49330cc into develop Jan 24, 2025
33 of 37 checks passed
@wjrosa wjrosa deleted the fix/fatal-error-editing-shortcode-checkout branch January 24, 2025 21:06
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.

Fatal error when editing the shortcode checkout page
2 participants