Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mike Jolley 2017-02-21 10:35:23 +00:00
commit eea4c1ae71
4 changed files with 23 additions and 14 deletions

View File

@ -370,7 +370,7 @@ class WC_Checkout {
* Action hook to adjust item before save. * Action hook to adjust item before save.
* @since 2.7.0 * @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. // Add item to order and save.
$order->add_item( $item ); $order->add_item( $item );
@ -401,7 +401,7 @@ class WC_Checkout {
* Action hook to adjust item before save. * Action hook to adjust item before save.
* @since 2.7.0 * @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. // Add item to order and save.
$order->add_item( $item ); $order->add_item( $item );
@ -437,7 +437,7 @@ class WC_Checkout {
* Action hook to adjust item before save. * Action hook to adjust item before save.
* @since 2.7.0 * @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. // Add item to order and save.
$order->add_item( $item ); $order->add_item( $item );
@ -467,7 +467,7 @@ class WC_Checkout {
* Action hook to adjust item before save. * Action hook to adjust item before save.
* @since 2.7.0 * @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. // Add item to order and save.
$order->add_item( $item ); $order->add_item( $item );
@ -493,7 +493,7 @@ class WC_Checkout {
* Action hook to adjust item before save. * Action hook to adjust item before save.
* @since 2.7.0 * @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. // Add item to order and save.
$order->add_item( $item ); $order->add_item( $item );

View File

@ -104,10 +104,12 @@ class WC_Order_Item_Tax extends WC_Order_Item {
* @throws WC_Data_Exception * @throws WC_Data_Exception
*/ */
public function set_rate( $tax_rate_id ) { 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_id( $tax_rate_id );
$this->set_rate_code( 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_code( $tax_rate_id ) ); $this->set_label( WC_Tax::get_rate_label( $tax_rate ) );
$this->set_compound( WC_Tax::get_rate_code( $tax_rate_id ) ); $this->set_compound( WC_Tax::is_compound( $tax_rate ) );
} }
/* /*

View File

@ -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. * @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 ) { public function get_variation_prices( $include_taxes = false ) {
$data_store = $this->get_data_store(); $prices = $this->data_store->read_price_data( $this, $include_taxes );
$prices = $data_store->read_price_data( $this, $include_taxes );
foreach ( $prices as $price_key => $variation_prices ) { foreach ( $prices as $price_key => $variation_prices ) {
$prices[ $price_key ] = $this->sort_variation_prices( $variation_prices ); $prices[ $price_key ] = $this->sort_variation_prices( $variation_prices );

View File

@ -594,12 +594,21 @@ class WC_Tax {
/** /**
* Return true/false depending on if a rate is a compound rate. * 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 * @return bool
*/ */
public static function is_compound( $key ) { public static function is_compound( $key_or_rate ) {
global $wpdb; 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 );
} }
/** /**