diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index a4d19f8e909..d75064d0869 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -113,30 +113,24 @@ function wc_clear_cart_after_payment() { if ( ! empty( $wp->query_vars['order-received'] ) ) { - $order_id = absint( $wp->query_vars['order-received'] ); - - if ( isset( $_GET['key'] ) ) - $order_key = $_GET['key']; - else - $order_key = ''; + $order_id = absint( $wp->query_vars['order-received'] ); + $order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : ''; if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); - if ( $order->order_key == $order_key ) { + if ( $order->order_key === $order_key ) { WC()->cart->empty_cart(); } } - } if ( WC()->session->order_awaiting_payment > 0 ) { - $order = wc_get_order( WC()->session->order_awaiting_payment ); if ( $order->id > 0 ) { // If the order has not failed, or is not pending, the order must have gone through - if ( ! $order->has_status( array( 'failed', 'pending' ) ) ) { + if ( ! $order->has_status( array( 'failed', 'pending', 'cancelled' ) ) ) { WC()->cart->empty_cart(); } } diff --git a/includes/widgets/class-wc-widget-price-filter.php b/includes/widgets/class-wc-widget-price-filter.php index 7197e578ee1..a57769a8107 100644 --- a/includes/widgets/class-wc-widget-price-filter.php +++ b/includes/widgets/class-wc-widget-price-filter.php @@ -49,11 +49,13 @@ class WC_Widget_Price_Filter extends WC_Widget { extract( $args ); - if ( ! is_post_type_archive( 'product' ) && ! is_tax( get_object_taxonomies( 'product' ) ) ) + if ( ! is_post_type_archive( 'product' ) && ! is_tax( get_object_taxonomies( 'product' ) ) ) { return; + } - if ( sizeof( WC()->query->unfiltered_product_ids ) == 0 ) + if ( sizeof( WC()->query->unfiltered_product_ids ) == 0 ) { return; // None shown - return + } $min_price = isset( $_GET['min_price'] ) ? esc_attr( $_GET['min_price'] ) : ''; $max_price = isset( $_GET['max_price'] ) ? esc_attr( $_GET['max_price'] ) : ''; @@ -65,20 +67,25 @@ class WC_Widget_Price_Filter extends WC_Widget { // Remember current filters/search $fields = ''; - if ( get_search_query() ) + if ( get_search_query() ) { $fields .= ''; + } - if ( ! empty( $_GET['post_type'] ) ) + if ( ! empty( $_GET['post_type'] ) ) { $fields .= ''; + } - if ( ! empty ( $_GET['product_cat'] ) ) + if ( ! empty ( $_GET['product_cat'] ) ) { $fields .= ''; + } - if ( ! empty( $_GET['product_tag'] ) ) + if ( ! empty( $_GET['product_tag'] ) ) { $fields .= ''; + } - if ( ! empty( $_GET['orderby'] ) ) + if ( ! empty( $_GET['orderby'] ) ) { $fields .= ''; + } if ( $_chosen_attributes ) foreach ( $_chosen_attributes as $attribute => $data ) { @@ -86,8 +93,9 @@ class WC_Widget_Price_Filter extends WC_Widget { $fields .= ''; - if ( $data['query_type'] == 'or' ) + if ( $data['query_type'] == 'or' ) { $fields .= ''; + } } $min = $max = 0; @@ -145,15 +153,17 @@ class WC_Widget_Price_Filter extends WC_Widget { ) ) ); } - if ( $min == $max ) + if ( $min == $max ) { return; + } echo $before_widget . $before_title . $title . $after_title; - if ( get_option( 'permalink_structure' ) == '' ) + if ( get_option( 'permalink_structure' ) == '' ) { $form_action = remove_query_arg( array( 'page', 'paged' ), add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); - else + } else { $form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( $wp->request ) ); + } echo '