diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index f8e60d6f5df..63007928cf4 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -370,7 +370,7 @@ class WC_Checkout { * Action hook to adjust item before save. * @since 2.7.0 */ - do_action( 'woocommerce_checkout_create_order_line_item', $item, $cart_item_key, $values ); + do_action( 'woocommerce_checkout_create_order_line_item', $item, $cart_item_key, $values, $order ); // Add item to order and save. $order->add_item( $item ); @@ -401,7 +401,7 @@ class WC_Checkout { * Action hook to adjust item before save. * @since 2.7.0 */ - do_action( 'woocommerce_checkout_create_order_fee_item', $item, $fee_key, $fee ); + do_action( 'woocommerce_checkout_create_order_fee_item', $item, $fee_key, $fee, $order ); // Add item to order and save. $order->add_item( $item ); @@ -437,7 +437,7 @@ class WC_Checkout { * Action hook to adjust item before save. * @since 2.7.0 */ - do_action( 'woocommerce_checkout_create_order_shipping_item', $item, $package_key, $package ); + do_action( 'woocommerce_checkout_create_order_shipping_item', $item, $package_key, $package, $order ); // Add item to order and save. $order->add_item( $item ); @@ -467,7 +467,7 @@ class WC_Checkout { * Action hook to adjust item before save. * @since 2.7.0 */ - do_action( 'woocommerce_checkout_create_order_tax_item', $item, $tax_rate_id ); + do_action( 'woocommerce_checkout_create_order_tax_item', $item, $tax_rate_id, $order ); // Add item to order and save. $order->add_item( $item ); @@ -493,7 +493,7 @@ class WC_Checkout { * Action hook to adjust item before save. * @since 2.7.0 */ - do_action( 'woocommerce_checkout_create_order_coupon_item', $item, $code, $coupon ); + do_action( 'woocommerce_checkout_create_order_coupon_item', $item, $code, $coupon, $order ); // Add item to order and save. $order->add_item( $item ); diff --git a/includes/class-wc-order-item-tax.php b/includes/class-wc-order-item-tax.php index db5d2dfae13..3eac790da8f 100644 --- a/includes/class-wc-order-item-tax.php +++ b/includes/class-wc-order-item-tax.php @@ -104,10 +104,12 @@ class WC_Order_Item_Tax extends WC_Order_Item { * @throws WC_Data_Exception */ public function set_rate( $tax_rate_id ) { + $tax_rate = WC_Tax::_get_tax_rate( $tax_rate_id, OBJECT ); + $this->set_rate_id( $tax_rate_id ); - $this->set_rate_code( WC_Tax::get_rate_code( $tax_rate_id ) ); - $this->set_label( WC_Tax::get_rate_code( $tax_rate_id ) ); - $this->set_compound( WC_Tax::get_rate_code( $tax_rate_id ) ); + $this->set_rate_code( WC_Tax::get_rate_code( $tax_rate ) ); + $this->set_label( WC_Tax::get_rate_label( $tax_rate ) ); + $this->set_compound( WC_Tax::is_compound( $tax_rate ) ); } /* diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index 5333c604e33..4d1e462361c 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -67,9 +67,7 @@ class WC_Product_Variable extends WC_Product { * @return array() Array of RAW prices, regular prices, and sale prices with keys set to variation ID. */ public function get_variation_prices( $include_taxes = false ) { - $data_store = $this->get_data_store(); - - $prices = $data_store->read_price_data( $this, $include_taxes ); + $prices = $this->data_store->read_price_data( $this, $include_taxes ); foreach ( $prices as $price_key => $variation_prices ) { $prices[ $price_key ] = $this->sort_variation_prices( $variation_prices ); diff --git a/includes/class-wc-tax.php b/includes/class-wc-tax.php index 036b41b3a8e..c8dcb9259f8 100644 --- a/includes/class-wc-tax.php +++ b/includes/class-wc-tax.php @@ -594,12 +594,21 @@ class WC_Tax { /** * Return true/false depending on if a rate is a compound rate. * - * @param int key + * @param mixed $key_or_rate Tax rate ID, or the db row itself in object format * @return bool */ - public static function is_compound( $key ) { + public static function is_compound( $key_or_rate ) { global $wpdb; - return $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ) ? true : false; + + if ( is_object( $key_or_rate ) ) { + $key = $key_or_rate->tax_rate_id; + $compound = $key_or_rate->tax_rate_compound; + } else { + $key = $key_or_rate; + $compound = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ) ? true : false; + } + + return (bool) apply_filters( 'woocommerce_rate_compound', $compound, $key ); } /**