Merge branch 'master' of github.com:woothemes/woocommerce
This commit is contained in:
commit
47492fb273
|
@ -1490,7 +1490,7 @@ abstract class WC_Abstract_Order {
|
|||
$price = ( $item['line_subtotal'] / max( 1, $item['qty'] ) );
|
||||
}
|
||||
|
||||
$price = $round ? number_format( (float) $price, 2, '.', '' ) : $price;
|
||||
$price = $round ? number_format( (float) $price, wc_get_price_decimals(), '.', '' ) : $price;
|
||||
|
||||
return apply_filters( 'woocommerce_order_amount_item_subtotal', $price, $this, $item, $inc_tax, $round );
|
||||
}
|
||||
|
@ -1504,14 +1504,13 @@ abstract class WC_Abstract_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) {
|
||||
|
||||
if ( $inc_tax ) {
|
||||
$price = $item['line_subtotal'] + $item['line_subtotal_tax'];
|
||||
} else {
|
||||
$price = $item['line_subtotal'];
|
||||
}
|
||||
|
||||
$price = $round ? round( $price, 2 ) : $price;
|
||||
$price = $round ? round( $price, wc_get_price_decimals() ) : $price;
|
||||
|
||||
return apply_filters( 'woocommerce_order_amount_line_subtotal', $price, $this, $item, $inc_tax, $round );
|
||||
}
|
||||
|
@ -1534,7 +1533,7 @@ abstract class WC_Abstract_Order {
|
|||
$price = $item['line_total'] / max( 1, $qty );
|
||||
}
|
||||
|
||||
$price = $round ? round( $price, 2 ) : $price;
|
||||
$price = $round ? round( $price, wc_get_price_decimals() ) : $price;
|
||||
|
||||
return apply_filters( 'woocommerce_order_amount_item_total', $price, $this, $item, $inc_tax, $round );
|
||||
}
|
||||
|
@ -1553,7 +1552,7 @@ abstract class WC_Abstract_Order {
|
|||
$line_total = $inc_tax ? $item['line_total'] + $item['line_tax'] : $item['line_total'];
|
||||
|
||||
// Check if we need to round
|
||||
$line_total = $round ? round( $line_total, 2 ) : $line_total;
|
||||
$line_total = $round ? round( $line_total, wc_get_price_decimals() ) : $line_total;
|
||||
|
||||
return apply_filters( 'woocommerce_order_amount_line_total', $line_total, $this, $item, $inc_tax, $round );
|
||||
}
|
||||
|
|
|
@ -1152,7 +1152,7 @@ class WC_Product {
|
|||
* @return array
|
||||
*/
|
||||
public function get_upsells() {
|
||||
return (array) maybe_unserialize( $this->upsell_ids );
|
||||
return apply_filters( 'woocommerce_product_upsell_ids', (array) maybe_unserialize( $this->upsell_ids ), $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1161,7 +1161,7 @@ class WC_Product {
|
|||
* @return array
|
||||
*/
|
||||
public function get_cross_sells() {
|
||||
return (array) maybe_unserialize( $this->crosssell_ids );
|
||||
return apply_filters( 'woocommerce_product_crosssell_ids', (array) maybe_unserialize( $this->crosssell_ids ), $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,11 @@ class WC_Meta_Box_Order_Items {
|
|||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
global $thepostid, $theorder;
|
||||
global $post, $thepostid, $theorder;
|
||||
|
||||
if ( ! is_int( $thepostid ) ) {
|
||||
$thepostid = $post->ID;
|
||||
}
|
||||
|
||||
if ( ! is_object( $theorder ) ) {
|
||||
$theorder = wc_get_order( $thepostid );
|
||||
|
|
|
@ -21,6 +21,7 @@ class WC_AJAX {
|
|||
* Hook in ajax handlers
|
||||
*/
|
||||
public static function init() {
|
||||
add_action( 'init', array( __CLASS__, 'define_ajax'), 0 );
|
||||
add_action( 'template_redirect', array( __CLASS__, 'do_wc_ajax'), 0 );
|
||||
self::add_ajax_events();
|
||||
}
|
||||
|
@ -34,6 +35,21 @@ class WC_AJAX {
|
|||
return esc_url_raw( add_query_arg( 'wc-ajax', $request ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set AJAX defines.
|
||||
*/
|
||||
public static function define_ajax() {
|
||||
|
||||
if ( ! empty( $_GET['wc-ajax'] ) ) {
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
define( 'DOING_AJAX', true );
|
||||
}
|
||||
if ( ! defined( 'WC_DOING_AJAX' ) ) {
|
||||
define( 'WC_DOING_AJAX', true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for WC Ajax request and fire action
|
||||
*/
|
||||
|
@ -45,12 +61,6 @@ class WC_AJAX {
|
|||
}
|
||||
|
||||
if ( $action = $wp_query->get( 'wc-ajax' ) ) {
|
||||
if ( ! defined( 'DOING_AJAX' ) ) {
|
||||
define( 'DOING_AJAX', true );
|
||||
}
|
||||
if ( ! defined( 'WC_DOING_AJAX' ) ) {
|
||||
define( 'WC_DOING_AJAX', true );
|
||||
}
|
||||
do_action( 'wc_ajax_' . sanitize_text_field( $action ) );
|
||||
die();
|
||||
}
|
||||
|
|
|
@ -634,16 +634,18 @@ class WC_Coupon {
|
|||
|
||||
// Handle the limit_usage_to_x_items option
|
||||
if ( $this->is_type( array( 'percent_product', 'fixed_product' ) ) ) {
|
||||
if ( '' === $this->limit_usage_to_x_items ) {
|
||||
$limit_usage_qty = $cart_item_qty;
|
||||
} else {
|
||||
$limit_usage_qty = min( $this->limit_usage_to_x_items, $cart_item_qty );
|
||||
$this->limit_usage_to_x_items = max( 0, $this->limit_usage_to_x_items - $limit_usage_qty );
|
||||
}
|
||||
if ( $single ) {
|
||||
$discount = ( $discount * $limit_usage_qty ) / $cart_item_qty;
|
||||
} else {
|
||||
$discount = ( $discount / $cart_item_qty ) * $limit_usage_qty;
|
||||
if ( $discounting_amount ) {
|
||||
if ( '' === $this->limit_usage_to_x_items ) {
|
||||
$limit_usage_qty = $cart_item_qty;
|
||||
} else {
|
||||
$limit_usage_qty = min( $this->limit_usage_to_x_items, $cart_item_qty );
|
||||
$this->limit_usage_to_x_items = max( 0, $this->limit_usage_to_x_items - $limit_usage_qty );
|
||||
}
|
||||
if ( $single ) {
|
||||
$discount = ( $discount * $limit_usage_qty ) / $cart_item_qty;
|
||||
} else {
|
||||
$discount = ( $discount / $cart_item_qty ) * $limit_usage_qty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
* @property string $state
|
||||
* @property string $postcode
|
||||
* @property string $city
|
||||
* @property string $address
|
||||
* @property string $address_1
|
||||
* @property string $address_2
|
||||
* @property string $shipping_country
|
||||
* @property string $shipping_state
|
||||
* @property string $shipping_postcode
|
||||
* @property string $shipping_city
|
||||
* @property string $shipping_address
|
||||
* @property string $shipping_address_1
|
||||
* @property string $shipping_address_2
|
||||
* @property string $is_vat_exempt
|
||||
* @property string $calculated_shipping
|
||||
|
@ -73,6 +73,12 @@ class WC_Customer {
|
|||
* @return bool
|
||||
*/
|
||||
public function __isset( $property ) {
|
||||
if ( 'address' === $property ) {
|
||||
$property = 'address_1';
|
||||
}
|
||||
if ( 'shipping_address' === $property ) {
|
||||
$property = 'shipping_address_1';
|
||||
}
|
||||
return isset( $this->_data[ $property ] );
|
||||
}
|
||||
|
||||
|
@ -83,6 +89,12 @@ class WC_Customer {
|
|||
* @return string
|
||||
*/
|
||||
public function __get( $property ) {
|
||||
if ( 'address' === $property ) {
|
||||
$property = 'address_1';
|
||||
}
|
||||
if ( 'shipping_address' === $property ) {
|
||||
$property = 'shipping_address_1';
|
||||
}
|
||||
return isset( $this->_data[ $property ] ) ? $this->_data[ $property ] : '';
|
||||
}
|
||||
|
||||
|
@ -93,6 +105,12 @@ class WC_Customer {
|
|||
* @param mixed $value
|
||||
*/
|
||||
public function __set( $property, $value ) {
|
||||
if ( 'address' === $property ) {
|
||||
$property = 'address_1';
|
||||
}
|
||||
if ( 'shipping_address' === $property ) {
|
||||
$property = 'shipping_address_1';
|
||||
}
|
||||
$this->_data[ $property ] = $value;
|
||||
$this->_changed = true;
|
||||
}
|
||||
|
@ -231,7 +249,7 @@ class WC_Customer {
|
|||
* @return string
|
||||
*/
|
||||
public function get_address() {
|
||||
return $this->address;
|
||||
return $this->address_1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,7 +303,7 @@ class WC_Customer {
|
|||
* @return string
|
||||
*/
|
||||
public function get_shipping_address() {
|
||||
return $this->shipping_address;
|
||||
return $this->shipping_address_1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,13 +358,13 @@ class WC_Customer {
|
|||
$this->_data = array(
|
||||
'postcode' => '',
|
||||
'city' => '',
|
||||
'address' => '',
|
||||
'address_1' => '',
|
||||
'address_2' => '',
|
||||
'state' => '',
|
||||
'country' => '',
|
||||
'shipping_postcode' => '',
|
||||
'shipping_city' => '',
|
||||
'shipping_address' => '',
|
||||
'shipping_address_1' => '',
|
||||
'shipping_address_2' => '',
|
||||
'shipping_state' => '',
|
||||
'shipping_country' => '',
|
||||
|
@ -435,16 +453,16 @@ class WC_Customer {
|
|||
* @param mixed $address
|
||||
*/
|
||||
public function set_address( $address ) {
|
||||
$this->address = $address;
|
||||
$this->address_1 = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address_2.
|
||||
* Sets session data for the $address.
|
||||
*
|
||||
* @param mixed $address_2
|
||||
* @param mixed $address
|
||||
*/
|
||||
public function set_address_2( $address_2 ) {
|
||||
$this->address_2 = $address_2;
|
||||
public function set_address_2( $address ) {
|
||||
$this->address_2 = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -504,16 +522,16 @@ class WC_Customer {
|
|||
* @param string $address
|
||||
*/
|
||||
public function set_shipping_address( $address ) {
|
||||
$this->shipping_address = $address;
|
||||
$this->shipping_address_1 = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets session data for the address_2.
|
||||
*
|
||||
* @param string $address_2
|
||||
* @param string $address
|
||||
*/
|
||||
public function set_shipping_address_2( $address_2 ) {
|
||||
$this->shipping_address_2 = $address_2;
|
||||
public function set_shipping_address_2( $address ) {
|
||||
$this->shipping_address_2 = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue