' . __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 = new WC_Order( $order_id ); if ( $order->status == 'pending' ) $wp->query_vars['order-pay'] = absint( $_GET['order'] ); else $wp->query_vars['order-received'] = absint( $_GET['order'] ); } // Handle checkout actions if ( ! empty( $wp->query_vars['order-pay'] ) ) { self::order_pay( $wp->query_vars['order-pay'] ); } elseif ( isset( $wp->query_vars['order-received'] ) ) { self::order_received( $wp->query_vars['order-received'] ); } else { self::checkout(); } } /** * Show the pay page */ private static function order_pay( $order_id ) { global $woocommerce; do_action( 'before_woocommerce_pay' ); wc_print_messages(); $order_id = absint( $order_id ); // Handle payment if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && $order_id ) { // Pay for existing order $order_key = urldecode( $_GET[ 'key' ] ); $order = new WC_Order( $order_id ); $valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ); if ( $order->id == $order_id && $order->order_key == $order_key ) { if ( in_array( $order->status, $valid_order_statuses ) ) { // Set customer location to order location if ( $order->billing_country ) $woocommerce->customer->set_country( $order->billing_country ); if ( $order->billing_state ) $woocommerce->customer->set_state( $order->billing_state ); if ( $order->billing_postcode ) $woocommerce->customer->set_postcode( $order->billing_postcode ); woocommerce_get_template( 'checkout/form-pay.php', array( 'order' => $order ) ); } else { $status = get_term_by('slug', $order->status, 'shop_order_status'); wc_add_error( sprintf( __( 'This order’s status is “%s”—it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), $status->name ) ); } } else { wc_add_error( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ) ); } } elseif ( $order_id ) { // Pay for order after checkout step $order_key = isset( $_GET['key'] ) ? woocommerce_clean( $_GET['key'] ) : ''; $order = new WC_Order( $order_id ); $valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ); if ( $order->id == $order_id && $order->order_key == $order_key ) { if ( in_array( $order->status, $valid_order_statuses ) ) { ?>