diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 3431cd746ba..76f5d492361 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -683,9 +683,10 @@ abstract class WC_Abstract_Order { } // Now calculate shipping tax - $matched_tax_rates = array(); $shipping_methods = $this->get_shipping_methods(); + if ( ! empty( $shipping_methods ) ) { + $matched_tax_rates = array(); $tax_rates = WC_Tax::find_rates( array( 'country' => $country, 'state' => $state, @@ -693,18 +694,21 @@ abstract class WC_Abstract_Order { 'city' => $city, 'tax_class' => '' ) ); - } - if ( ! empty( $tax_rates ) ) { - foreach ( $tax_rates as $key => $rate ) { - if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) { - $matched_tax_rates[ $key ] = $rate; + if ( ! empty( $tax_rates ) ) { + foreach ( $tax_rates as $key => $rate ) { + if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) { + $matched_tax_rates[ $key ] = $rate; + } } } - } - $shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates ); - $shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) ); + $shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates ); + $shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) ); + } else { + $shipping_taxes = array(); + $shipping_tax_total = 0; + } // Save tax totals $this->set_total( $shipping_tax_total, 'shipping_tax' ); diff --git a/includes/admin/class-wc-admin.php b/includes/admin/class-wc-admin.php index 883aa5de4e5..61599dc2dd0 100644 --- a/includes/admin/class-wc-admin.php +++ b/includes/admin/class-wc-admin.php @@ -100,7 +100,7 @@ class WC_Admin { delete_transient( '_wc_activation_redirect' ); - if ( ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'wc-setup' ) ) ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_woocommerce' ) ) { + if ( ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'wc-setup' ) ) ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_woocommerce' ) || apply_filters( 'woocommerce_prevent_automatic_wizard_redirect', false ) ) { return; } diff --git a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php index cb0ae2e2ddb..5ef07b777d5 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php @@ -984,7 +984,6 @@ class WC_Meta_Box_Product_Data { update_post_meta( $post_id, '_sale_price', '' ); update_post_meta( $post_id, '_sale_price_dates_from', '' ); update_post_meta( $post_id, '_sale_price_dates_to', '' ); - update_post_meta( $post_id, '_price', '' ); } else { $date_from = isset( $_POST['_sale_price_dates_from'] ) ? wc_clean( $_POST['_sale_price_dates_from'] ) : ''; diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index 7de02994d96..ae9d9f93c9c 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -720,8 +720,11 @@ class WC_Product_Variable extends WC_Product { ) ); // No published variations - product won't be purchasable. - if ( ! $children && 'publish' === get_post_status( $product_id ) ) { - if ( is_admin() ) { + if ( ! $children ) { + update_post_meta( $product_id, '_price', '' ); + delete_transient( 'wc_products_onsale' ); + + if ( is_admin() && 'publish' === get_post_status( $product_id ) ) { WC_Admin_Meta_Boxes::add_error( __( 'This variable product has no active variations. Add or enable variations to allow this product to be purchased.', 'woocommerce' ) ); } diff --git a/includes/class-wc-tax.php b/includes/class-wc-tax.php index c92b95a2bf7..e89fd5ce18f 100644 --- a/includes/class-wc-tax.php +++ b/includes/class-wc-tax.php @@ -442,11 +442,12 @@ class WC_Tax { // This will be per order shipping - loop through the order and find the highest tax class rate $cart_tax_classes = WC()->cart->get_cart_item_tax_classes(); - // If multiple classes are found, use highest. Don't bother with standard rate, we can get that later. + // If multiple classes are found, use the first one. Don't bother with standard rate, we can get that later. if ( sizeof( $cart_tax_classes ) > 1 && ! in_array( '', $cart_tax_classes ) ) { $tax_classes = self::get_tax_classes(); foreach ( $tax_classes as $tax_class ) { + $tax_class = sanitize_title( $tax_class ); if ( in_array( $tax_class, $cart_tax_classes ) ) { $matched_tax_rates = self::find_shipping_rates( array( 'country' => $country,