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

Check if cart exists before calling a method #604

Closed
wants to merge 2 commits into from

Conversation

Narek13
Copy link
Collaborator

@Narek13 Narek13 commented Apr 14, 2022

Issue: #603


Description

There are multiple errors reported:

2022-04-07T09:18:27+00:00 CRITICAL Uncaught Error: Call to a member function get_cart_contents_total() on null in /chroot/home/a4084adf/wealthyhair.com/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php:1127
Stack trace:
#0 /chroot/home/a4084adf/wealthyhair.com/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(378): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->is_cart_price_total_zero()
#1 /chroot/home/a4084adf/wealthyhair.com/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(195): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->render_button_wrapper_registrar()
#2 /chroot/home/a4084adf/wealthyhair.com/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/ButtonModule.php(56): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->render_wrapper()
#3 /chroot/home/a4084adf/wealthyhair.com/html/wp-includes/class-wp-hook.php(307): WooCommerce\PayPalCommerce\Button\But in /chroot/home/a4084adf/wealthyhair.com/html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php on line 1127

The PR will fix the error by adding a check if WC()->cart exists.

Steps to Test

not quite sure how to reproduce but there are multiple reports.


Closes #603 .

@Narek13 Narek13 requested a review from Dinamiko April 14, 2022 15:16
@braddalton
Copy link

braddalton commented May 18, 2022

Any idea when this fix will be committed? I can't use WooCommerce Payments because i'm in a excluded country. There are others reporting this issue with PP CC payments on front end losing sales.

2022-05-15T17:44:18+00:00 CRITICAL Uncaught Error: Call to a member function get_cart_contents_total() on null in /nas/content/live/wpsites/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php:1227
Stack trace:
#0 /nas/content/live/wpsites/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(448): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->is_cart_price_total_zero()
#1 /nas/content/live/wpsites/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php(229): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->render_button_wrapper_registrar()
#2 /nas/content/live/wpsites/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/ButtonModule.php(57): WooCommerce\PayPalCommerce\Button\Assets\SmartButton->render_wrapper()
#3 /nas/content/live/wpsites/wp-includes/class-wp-hook.php(307): WooCommerce\PayPalCommerce\Button\ButtonModule::WooCommerce\PayPalCommerce\Button{closure}(Object(WP))
#4 /nas/content/li in /nas/content/live/wpsites/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/src/Assets/SmartButton.php on line 1227

@InpsydeNiklas
Copy link
Member

resolved in #606

@Dinamiko Dinamiko deleted the PCP-635-type-error-on-cart-total-check branch May 18, 2022 09:41
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.

type error on cart total check with get_cart_contents_total() on null (635)
4 participants