Tax class fixes + notices
This commit is contained in:
parent
0f22691767
commit
93778e72b0
|
@ -451,7 +451,6 @@ jQuery( function($){
|
|||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
|
||||
if ( response ) {
|
||||
$items.each( function() {
|
||||
var $row = $(this);
|
||||
|
|
|
@ -41,11 +41,11 @@ class WC_Order {
|
|||
global $wpdb;
|
||||
|
||||
if ( $type ) {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s )", $order_id, $type ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s", $order_id, $type ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s )", $this->id, $type ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s", $this->id, $type ) );
|
||||
} else {
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d )", $order_id ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d", $order_id ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d )", $this->id ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d", $this->id ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,8 @@ class WC_Order {
|
|||
}
|
||||
|
||||
wc_add_order_item_meta( $item_id, 'rate_id', $tax_rate_id );
|
||||
wc_add_order_item_meta( $item_id, 'label', WC_Tax::get_rate_label( $key ) );
|
||||
wc_add_order_item_meta( $item_id, 'compound', WC_Tax::is_compound( $key ) ? 1 : 0 );
|
||||
wc_add_order_item_meta( $item_id, 'label', WC_Tax::get_rate_label( $tax_rate_id ) );
|
||||
wc_add_order_item_meta( $item_id, 'compound', WC_Tax::is_compound( $tax_rate_id ) ? 1 : 0 );
|
||||
wc_add_order_item_meta( $item_id, 'tax_amount', wc_format_decimal( $tax_amount ) );
|
||||
wc_add_order_item_meta( $item_id, 'shipping_tax_amount', wc_format_decimal( $shipping_tax_amount ) );
|
||||
|
||||
|
@ -354,7 +354,7 @@ class WC_Order {
|
|||
|
||||
// Now merge to keep tax rows
|
||||
foreach ( array_keys( $taxes + $shipping_taxes ) as $tax_rate_id ) {
|
||||
$this->add_tax( $tax_rate_id, isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0, isset( $shipping_taxes[ $key ] ) ? $shipping_taxes[ $key ] : 0 );
|
||||
$this->add_tax( $tax_rate_id, isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ] : 0, isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1284,7 +1284,7 @@ class WC_Order {
|
|||
* @return WC_Product
|
||||
*/
|
||||
public function get_product_from_item( $item ) {
|
||||
$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
||||
$_product = get_product( ! empty( $item['variation_id'] ) ? $item['variation_id'] : $item['product_id'] );
|
||||
|
||||
return apply_filters( 'woocommerce_get_product_from_item', $_product, $item, $this );
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class WC_Tax {
|
|||
*/
|
||||
public static function calc_tax( $price, $rates, $price_includes_tax = false, $suppress_rounding = false ) {
|
||||
// Work in pence to X precision
|
||||
$price = self::$precision( $price );
|
||||
$price = self::precision( $price );
|
||||
|
||||
if ( $price_includes_tax )
|
||||
$taxes = self::calc_inclusive_tax( $price, $rates );
|
||||
|
@ -47,7 +47,7 @@ class WC_Tax {
|
|||
|
||||
// Remove precision
|
||||
$price = self::remove_precision( $price );
|
||||
$taxes = array_map( array( $this, 'remove_precision' ), $taxes );
|
||||
$taxes = array_map( array( __CLASS__, 'remove_precision' ), $taxes );
|
||||
|
||||
return apply_filters( 'woocommerce_calc_tax', $taxes, $price, $rates, $price_includes_tax, $suppress_rounding );
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ class WC_Tax {
|
|||
if ( ! $rate_name )
|
||||
$rate_name = WC()->countries->tax_or_vat();
|
||||
|
||||
return apply_filters( 'woocommerce_rate_label', $rate_name, $key, $this );
|
||||
return apply_filters( 'woocommerce_rate_label', $rate_name, $key );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -554,7 +554,7 @@ class WC_Tax {
|
|||
$code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX';
|
||||
$code[] = absint( $rate->tax_rate_priority );
|
||||
|
||||
return apply_filters( 'woocommerce_rate_code', strtoupper( implode( '-', array_filter( $code ) ) ), $key, $this );
|
||||
return apply_filters( 'woocommerce_rate_code', strtoupper( implode( '-', array_filter( $code ) ) ), $key );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -564,7 +564,7 @@ class WC_Tax {
|
|||
* @return float
|
||||
*/
|
||||
public static function get_tax_total( $taxes ) {
|
||||
return array_sum( array_map( array( $this, 'round' ), $taxes ) );
|
||||
return array_sum( array_map( array( __CLASS__, 'round' ), $taxes ) );
|
||||
}
|
||||
}
|
||||
WC_Tax::init();
|
Loading…
Reference in New Issue