Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Avoid a fatal error on the order received page if the order ID is not for a valid order.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private static function order_received( $order_id = 0 ) {
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );

if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) {
if ( ( ! $order instanceof WC_Order ) || ! hash_equals( $order->get_order_key(), $order_key ) ) {
$order = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/woocommerce/includes/wc-cart-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function wc_clear_cart_after_payment() {
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );

if ( $order && hash_equals( $order->get_order_key(), $order_key ) ) {
if ( $order instanceof WC_Order && hash_equals( $order->get_order_key(), $order_key ) ) {
WC()->cart->empty_cart();
}
}
Expand All @@ -185,7 +185,7 @@ function wc_clear_cart_after_payment() {
if ( WC()->session->order_awaiting_payment > 0 ) {
$order = wc_get_order( WC()->session->order_awaiting_payment );

if ( $order && $order->get_id() > 0 ) {
if ( $order instanceof WC_Order && $order->get_id() > 0 ) {
// If the order has not failed, or is not pending, the order must have gone through.
if ( ! $order->has_status( array( 'failed', 'pending', 'cancelled' ) ) ) {
WC()->cart->empty_cart();
Expand Down