Merge pull request #5967 from SiR-DanieL/master

Fixed issue #5895
This commit is contained in:
Mike Jolley 2014-08-05 10:49:40 +01:00
commit 49b597665e
3 changed files with 51 additions and 26 deletions

View File

@ -37,7 +37,7 @@ jQuery(function(){
if ( value !== newvalue ) {
jQuery(this).val( newvalue );
if ( jQuery(this).parent().find('.wc_error_tip').size() == 0 ) {
if ( jQuery(this).parent().find('.wc_error_tip').size() === 0 ) {
var offset = jQuery(this).position();
jQuery(this).after( '<div class="wc_error_tip">' + woocommerce_admin.i18n_decimal_error + '</div>' );
jQuery('.wc_error_tip')
@ -49,6 +49,30 @@ jQuery(function(){
return this;
});
jQuery('body').on('keyup change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){
var sale_price_field = jQuery(this);
var sale_price = parseInt( sale_price_field.val() );
if( sale_price_field.attr('name').indexOf('variable') !== -1 ) {
var regular_price = parseInt(sale_price_field.parents('.variable_pricing').find('.wc_input_price[name^=variable_regular_price]').val());
} else {
var regular_price = parseInt(jQuery('#_regular_price').val());
}
if( sale_price >= regular_price ) {
jQuery(this).val( regular_price );
if ( jQuery(this).parent().find('.wc_error_tip').size() === 0 ) {
var offset = jQuery(this).position();
jQuery(this).after( '<div class="wc_error_tip">' + woocommerce_admin.i18_sale_less_than_regular_error + '</div>' );
jQuery('.wc_error_tip')
.css('left', offset.left + jQuery(this).width() - ( jQuery(this).width() / 2 ) - ( jQuery('.wc_error_tip').width() / 2 ) )
.css('top', offset.top + jQuery(this).height() )
.fadeIn('100');
}
}
return this;
});
jQuery('body').on('keyup change', '.wc_input_country_iso[type=text]', function(){
var value = jQuery(this).val();
var regex = new RegExp( '^([A-Z])?([A-Z])$' );

File diff suppressed because one or more lines are too long

View File

@ -83,40 +83,41 @@ class WC_Admin_Assets {
wp_register_script( 'chosen', WC()->plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), WC_VERSION );
// Accounting
$params = array(
$params = array(
'mon_decimal_point' => get_option( 'woocommerce_price_decimal_sep' )
);
);
wp_localize_script( 'accounting', 'accounting_params', $params );
wp_localize_script( 'accounting', 'accounting_params', $params );
// WooCommerce admin pages
if ( in_array( $screen->id, wc_get_screen_ids() ) ) {
if ( in_array( $screen->id, wc_get_screen_ids() ) ) {
wp_enqueue_script( 'woocommerce_admin' );
wp_enqueue_script( 'iris' );
wp_enqueue_script( 'ajax-chosen' );
wp_enqueue_script( 'chosen' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'woocommerce_admin' );
wp_enqueue_script( 'iris' );
wp_enqueue_script( 'ajax-chosen' );
wp_enqueue_script( 'chosen' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
$locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$params = array(
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), get_option( 'woocommerce_price_decimal_sep' ) ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => get_option( 'woocommerce_price_decimal_sep' )
);
$params = array(
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), get_option( 'woocommerce_price_decimal_sep' ) ),
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => get_option( 'woocommerce_price_decimal_sep' ),
);
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
}
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
}
// Edit product category pages
if ( in_array( $screen->id, array( 'edit-product_cat' ) ) ) {
// Edit product category pages
if ( in_array( $screen->id, array( 'edit-product_cat' ) ) ) {
wp_enqueue_media();
}
}
// Products
if ( in_array( $screen->id, array( 'edit-product' ) ) ) {