diff --git a/includes/admin/post-types/class-wc-admin-cpt-shop_order.php b/includes/admin/post-types/class-wc-admin-cpt-shop_order.php index d7f086cca70..22b23f64e35 100644 --- a/includes/admin/post-types/class-wc-admin-cpt-shop_order.php +++ b/includes/admin/post-types/class-wc-admin-cpt-shop_order.php @@ -566,15 +566,6 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT { // Search orders $post_ids = array_unique( array_merge( - $wpdb->get_col( - $wpdb->prepare( " - SELECT post_id - FROM {$wpdb->postmeta} - WHERE meta_key IN ('" . implode( "','", $search_fields ) . "') AND meta_value LIKE '%%%s%%' - ", - esc_attr( $_GET['s'] ) - ) - ), $wpdb->get_col( $wpdb->prepare( " SELECT p1.post_id @@ -584,8 +575,10 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT { ( p1.meta_key = '_billing_first_name' AND p2.meta_key = '_billing_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' ) OR ( p1.meta_key = '_shipping_first_name' AND p2.meta_key = '_shipping_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' ) + OR + ( p1.meta_key IN ('" . implode( "','", $search_fields ) . "') AND p1.meta_value LIKE '%%%s%%' ) ", - esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ) + esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ) ) ), $wpdb->get_col( diff --git a/includes/api/class-wc-api-server.php b/includes/api/class-wc-api-server.php index 8d78bf7bfd0..abba1b698d8 100644 --- a/includes/api/class-wc-api-server.php +++ b/includes/api/class-wc-api-server.php @@ -576,7 +576,7 @@ class WC_API_Server { } /** - * Returns the request URL with the page query parmeter set to the specified page + * Returns the request URL with the page query parameter set to the specified page * * @since 2.1 * @param int $page @@ -590,8 +590,10 @@ class WC_API_Server { // add provided page query param $request = urldecode( add_query_arg( 'page', $page, $request ) ); - // return full URL - return get_woocommerce_api_url( str_replace( '/wc-api/v1/', '', $request ) ); + // get the home host + $host = parse_url( get_home_url(), PHP_URL_HOST ); + + return set_url_scheme( "http://{$host}{$request}" ); } /** diff --git a/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php b/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php index ad2cb449a26..49173d4913c 100644 --- a/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php +++ b/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php @@ -256,7 +256,15 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { $extra_rate['label'] = $this_option[0]; $this_cost = $this_option[1]; - if (preg_match('/(\d+\.?\d*)\s*(\+|-)\s*(\d+\.?\d*)\%/', $this_cost, $this_cost_matches)) { + $pattern = + '/' . // start regex + '(\d+\.?\d*)' . // capture digits, optionally capture a `.` and more digits + '\s*' . // match whitespace + '(\+|-)' . // capture the operand + '\s*'. // match whitespace + '(\d+\.?\d*)'. // capture digits, optionally capture a `.` and more digits + '\%/'; // match the percent sign & end regex + if ( preg_match( $pattern, $this_cost, $this_cost_matches ) ) { $this_cost_mathop = $this_cost_matches[2]; $this_cost_percents = $this_cost_matches[3] / 100; $this_cost = $this_cost_matches[1]; @@ -280,12 +288,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { if ( $this_cost_percents ) { foreach ( $this->find_shipping_classes( $package ) as $shipping_class => $items ){ foreach ( $items as $item_id => $values ) { - if ($this_cost_mathop == '+') { - $this_cost += $this_cost_percents * $values['line_total']; - } - else { - $this_cost -= $this_cost_percents * $values['line_total']; - } + $this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $values['line_total'] ); } } } @@ -296,22 +299,14 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { // Factor $this_cost by the percentage if provided. if ( $this_cost_percents ) { foreach ( $package['contents'] as $item_id => $values ) { - if ($this_cost_mathop == '+') { - $this_cost += $this_cost_percents * $values['line_total']; - } else { - $this_cost -= $this_cost_percents * $values['line_total']; - } + $this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $values['line_total'] ); } } break; case 'order' : // Factor $this_cost by the percentage if provided. if ( $this_cost_percents ) { - if ($this_cost_mathop == '+') { - $this_cost += $this_cost_percents * $package['contents_cost']; - } else { - $this_cost -= $this_cost_percents * $package['contents_cost']; - } + $this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $package['contents_cost'] ); } break; } @@ -328,6 +323,27 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { } + /** + * Calculate the percentage adjustment for each shipping rate. + * + * @access public + * @param float $cost + * @param float $percent_adjustment + * @param string $percent_operator + * @param float $base_price + * @return float + */ + function calc_percentage_adjustment( $cost, $percent_adjustment, $percent_operator, $base_price ) { + if ( '+' == $percent_operator ) { + $cost += $percent_adjustment * $base_price; + } else { + $cost -= $percent_adjustment * $base_price; + } + + return $cost; + } + + /** * order_shipping function. * diff --git a/includes/shortcodes/class-wc-shortcode-my-account.php b/includes/shortcodes/class-wc-shortcode-my-account.php index 4c19cf808f7..6d764007f5c 100644 --- a/includes/shortcodes/class-wc-shortcode-my-account.php +++ b/includes/shortcodes/class-wc-shortcode-my-account.php @@ -212,7 +212,7 @@ class WC_Shortcode_My_Account { wc_add_notice( __( 'Enter a username or e-mail address.', 'woocommerce' ), 'error' ); - } elseif ( strpos( $_POST['user_login'], '@' ) ) { + } elseif ( strpos( $_POST['user_login'], '@' ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) { $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) ); @@ -223,7 +223,7 @@ class WC_Shortcode_My_Account { $login = trim( $_POST['user_login'] ); - $user_data = get_user_by('login', $login ); + $user_data = get_user_by( 'login', $login ); } do_action('lostpassword_post'); diff --git a/templates/cart/cart-item-data.php b/templates/cart/cart-item-data.php index a77a5b5118d..9ab4685df3f 100644 --- a/templates/cart/cart-item-data.php +++ b/templates/cart/cart-item-data.php @@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly foreach ( $item_data as $data ) : $key = sanitize_text_field( $data['key'] ); ?> -
:
-
+
:
+