Prevent non-WC_Orders on the order received page
To ensure they have an implementation of the get_order_key function. Visits to the order_received page with the id of a refund result in a fatal error.
This commit is contained in:
parent
6e93e8d35e
commit
e3a179ff1c
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
No longer fatals on order-received page when provided with the id of a refund
|
|
@ -271,7 +271,7 @@ class WC_Shortcode_Checkout {
|
||||||
if ( $order_id > 0 ) {
|
if ( $order_id > 0 ) {
|
||||||
$order = wc_get_order( $order_id );
|
$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;
|
$order = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ function wc_clear_cart_after_payment() {
|
||||||
if ( $order_id > 0 ) {
|
if ( $order_id > 0 ) {
|
||||||
$order = wc_get_order( $order_id );
|
$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();
|
WC()->cart->empty_cart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue