commit
5463e18998
|
@ -683,9 +683,10 @@ abstract class WC_Abstract_Order {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now calculate shipping tax
|
// Now calculate shipping tax
|
||||||
$matched_tax_rates = array();
|
|
||||||
$shipping_methods = $this->get_shipping_methods();
|
$shipping_methods = $this->get_shipping_methods();
|
||||||
|
|
||||||
if ( ! empty( $shipping_methods ) ) {
|
if ( ! empty( $shipping_methods ) ) {
|
||||||
|
$matched_tax_rates = array();
|
||||||
$tax_rates = WC_Tax::find_rates( array(
|
$tax_rates = WC_Tax::find_rates( array(
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
'state' => $state,
|
'state' => $state,
|
||||||
|
@ -693,18 +694,21 @@ abstract class WC_Abstract_Order {
|
||||||
'city' => $city,
|
'city' => $city,
|
||||||
'tax_class' => ''
|
'tax_class' => ''
|
||||||
) );
|
) );
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $tax_rates ) ) {
|
if ( ! empty( $tax_rates ) ) {
|
||||||
foreach ( $tax_rates as $key => $rate ) {
|
foreach ( $tax_rates as $key => $rate ) {
|
||||||
if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) {
|
if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) {
|
||||||
$matched_tax_rates[ $key ] = $rate;
|
$matched_tax_rates[ $key ] = $rate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates );
|
$shipping_taxes = WC_Tax::calc_shipping_tax( $this->order_shipping, $matched_tax_rates );
|
||||||
$shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
|
$shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
|
||||||
|
} else {
|
||||||
|
$shipping_taxes = array();
|
||||||
|
$shipping_tax_total = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Save tax totals
|
// Save tax totals
|
||||||
$this->set_total( $shipping_tax_total, 'shipping_tax' );
|
$this->set_total( $shipping_tax_total, 'shipping_tax' );
|
||||||
|
|
|
@ -100,7 +100,7 @@ class WC_Admin {
|
||||||
|
|
||||||
delete_transient( '_wc_activation_redirect' );
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -984,7 +984,6 @@ class WC_Meta_Box_Product_Data {
|
||||||
update_post_meta( $post_id, '_sale_price', '' );
|
update_post_meta( $post_id, '_sale_price', '' );
|
||||||
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
||||||
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
||||||
update_post_meta( $post_id, '_price', '' );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$date_from = isset( $_POST['_sale_price_dates_from'] ) ? wc_clean( $_POST['_sale_price_dates_from'] ) : '';
|
$date_from = isset( $_POST['_sale_price_dates_from'] ) ? wc_clean( $_POST['_sale_price_dates_from'] ) : '';
|
||||||
|
|
|
@ -720,8 +720,11 @@ class WC_Product_Variable extends WC_Product {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// No published variations - product won't be purchasable.
|
// No published variations - product won't be purchasable.
|
||||||
if ( ! $children && 'publish' === get_post_status( $product_id ) ) {
|
if ( ! $children ) {
|
||||||
if ( is_admin() ) {
|
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' ) );
|
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' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,11 +442,12 @@ class WC_Tax {
|
||||||
// This will be per order shipping - loop through the order and find the highest tax class rate
|
// 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();
|
$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 ) ) {
|
if ( sizeof( $cart_tax_classes ) > 1 && ! in_array( '', $cart_tax_classes ) ) {
|
||||||
$tax_classes = self::get_tax_classes();
|
$tax_classes = self::get_tax_classes();
|
||||||
|
|
||||||
foreach ( $tax_classes as $tax_class ) {
|
foreach ( $tax_classes as $tax_class ) {
|
||||||
|
$tax_class = sanitize_title( $tax_class );
|
||||||
if ( in_array( $tax_class, $cart_tax_classes ) ) {
|
if ( in_array( $tax_class, $cart_tax_classes ) ) {
|
||||||
$matched_tax_rates = self::find_shipping_rates( array(
|
$matched_tax_rates = self::find_shipping_rates( array(
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
|
|
Loading…
Reference in New Issue