From e4b092fe10ca6fab472395e620b1cbf39762c6e8 Mon Sep 17 00:00:00 2001 From: Kevin Hagerty Date: Sat, 5 Sep 2015 08:06:57 -0400 Subject: [PATCH 1/3] Use the needs_payment function Instead of checking against a list of valid order statuses, use the needs_payment function which already checks against those statuses --- includes/shortcodes/class-wc-shortcode-checkout.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index 406b948f047..a952471cc8e 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -84,8 +84,7 @@ class WC_Shortcode_Checkout { // Pay for existing order $order_key = $_GET[ 'key' ]; $order = wc_get_order( $order_id ); - $valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ); - + if ( ! current_user_can( 'pay_for_order', $order_id ) ) { echo '
' . __( 'Invalid order. If you have an account please log in and try again.', 'woocommerce' ) . ' ' . __( 'My Account', 'woocommerce' ) . '' . '
'; return; @@ -93,7 +92,7 @@ class WC_Shortcode_Checkout { if ( $order->id == $order_id && $order->order_key == $order_key ) { - if ( $order->has_status( $valid_order_statuses ) ) { + if ( $order->needs_payment() ) { // Set customer location to order location if ( $order->billing_country ) @@ -118,11 +117,10 @@ class WC_Shortcode_Checkout { // Pay for order after checkout step $order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : ''; $order = wc_get_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 ( $order->has_status( $valid_order_statuses ) ) { + if ( $order->needs_payment() ) { ?>