Fix - When bulk editing, don't allow sale price to be negative.

Fixes #6325
This commit is contained in:
Mike Jolley 2014-09-19 12:18:04 +01:00
parent 1fb8582acf
commit 8f62f00f4d
2 changed files with 9 additions and 8 deletions

View File

@ -1012,9 +1012,9 @@ class WC_Admin_Post_Types {
case 3 :
if ( strstr( $regular_price, '%' ) ) {
$percent = str_replace( '%', '', $regular_price ) / 100;
$new_price = $old_regular_price - ( round ( $old_regular_price * $percent, absint( get_option( 'woocommerce_price_num_decimals' ) ) ) );
$new_price = max( 0, $old_regular_price - ( round ( $old_regular_price * $percent, absint( get_option( 'woocommerce_price_num_decimals' ) ) ) ) );
} else {
$new_price = $old_regular_price - $regular_price;
$new_price = max( 0, $old_regular_price - $regular_price );
}
break;
@ -1033,7 +1033,7 @@ class WC_Admin_Post_Types {
if ( ! empty( $_REQUEST['change_sale_price'] ) ) {
$change_sale_price = absint( $_REQUEST['change_sale_price'] );
$sale_price = esc_attr( stripslashes( $_REQUEST['_sale_price'] ) );
$sale_price = esc_attr( stripslashes( $_REQUEST['_sale_price'] ) );
switch ( $change_sale_price ) {
case 1 :
@ -1050,17 +1050,17 @@ class WC_Admin_Post_Types {
case 3 :
if ( strstr( $sale_price, '%' ) ) {
$percent = str_replace( '%', '', $sale_price ) / 100;
$new_price = $old_sale_price - ( $old_sale_price * $percent );
$new_price = max( 0, $old_sale_price - ( $old_sale_price * $percent ) );
} else {
$new_price = $old_sale_price - $sale_price;
$new_price = max( 0, $old_sale_price - $sale_price );
}
break;
case 4 :
if ( strstr( $sale_price, '%' ) ) {
$percent = str_replace( '%', '', $sale_price ) / 100;
$new_price = $product->regular_price - ( $product->regular_price * $percent );
$new_price = max( 0, $product->regular_price - ( $product->regular_price * $percent ) );
} else {
$new_price = $product->regular_price - $sale_price;
$new_price = max( 0, $product->regular_price - $sale_price );
}
break;

View File

@ -131,7 +131,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 2.2.5 =
* Fix - Filters in admin screen for coupons and orders
* Fix - Filters in admin screen for coupons and orders.
* Fix - When bulk editing, don't allow sale price to be negative.
* Tweak - Tweak load_plugin_textdomain to be relative - this falls back to WP_LANG_DIR automatically. Can prevent "open_basedir restriction in effect".
= 2.2.4 - 18/09/2014 =