From a9a6009b666971bff5650f9d3b07b907577cdca6 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Sat, 15 Aug 2015 17:50:42 -0300 Subject: [PATCH] Check if order is valid in checkout shortcode, closes #8829 --- includes/shortcodes/class-wc-shortcode-checkout.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 ) {