diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index 5e2a4c0abd7..406b948f047 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -39,10 +39,10 @@ class WC_Shortcode_Checkout { _deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.' ); // Get the order to work out what we are showing - $order_id = absint( $_GET['order'] ); - $order = wc_get_order( $order_id ); + $order_id = absint( $_GET['order'] ); + $order = wc_get_order( $order_id ); - if ( $order->has_status( 'pending' ) ) { + if ( $order && $order->has_status( 'pending' ) ) { $wp->query_vars['order-pay'] = absint( $_GET['order'] ); } else { $wp->query_vars['order-received'] = absint( $_GET['order'] ); @@ -67,6 +67,8 @@ class WC_Shortcode_Checkout { /** * Show the pay page + * + * @param int $order_id */ private static function order_pay( $order_id ) { @@ -170,6 +172,8 @@ class WC_Shortcode_Checkout { /** * Show the thanks page + * + * @param int $order_id */ private static function order_received( $order_id = 0 ) {