Fix warning: Attempt to read property "order_awaiting_payment" on null (#45821)

This commit is contained in:
mujuonly 2024-07-24 06:39:44 +05:30 committed by GitHub
parent d5dcf91ee2
commit 9fbf143df9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Check if there's an actual session available inside wc_clear_cart_after_payment

View File

@ -184,7 +184,7 @@ function wc_clear_cart_after_payment() {
}
}
if ( WC()->session->order_awaiting_payment > 0 ) {
if ( is_object( WC()->session ) && WC()->session->order_awaiting_payment > 0 ) {
$order = wc_get_order( WC()->session->order_awaiting_payment );
if ( $order instanceof WC_Order && $order->get_id() > 0 ) {