Merge branch 'master' into estonian-translation

This commit is contained in:
Illimar Tambek 2013-10-07 20:40:20 +03:00
commit 2536fbc5e1
46 changed files with 1838 additions and 1514 deletions

File diff suppressed because one or more lines are too long

View File

@ -2749,7 +2749,7 @@ img.tips {
#tiptip_content, .chart-tooltip, .wc_error_tip {
font-size: 11px;
color: #fff;
padding: .75em 1em;
padding: .5em .5em;
background:#464646;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
@ -2774,6 +2774,7 @@ img.tips {
.wc_error_tip {
background: #d82223;
max-width: 20em;
white-space: normal;
position: absolute;
margin: 1.5em 1px 0 -1em;
z-index: 9999999;

View File

@ -4,32 +4,29 @@
jQuery(function(){
// Price input validation - Keep price inputs formatted correctly
jQuery(".wc_input_price[type=text]")
jQuery(".wc_input_decimal[type=text]")
.each(function(){
var value = jQuery(this).val();
var newvalue = value.replace( '.', woocommerce_admin.locale_decimal_point );
jQuery(this).val( newvalue );
});
jQuery(".wc_input_decimal[type=text]")
.bind( 'keyup change', function() {
var value = jQuery(this).val();
var newvalue = value.replace(/[^0-9.]+/g, '');
// Allow 1 decimal point
if ( newvalue.indexOf('.') != -1 ) {
var splitvalue = newvalue.split( '.' );
if ( splitvalue.length > 2 ) {
newvalue = splitvalue[0] + '.' + splitvalue[1];
}
}
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.locale_decimal_point + "]+", "gi" );
var newvalue = value.replace( regex, '' );
if ( value !== newvalue ) {
jQuery(this).val( newvalue );
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_price_input_error + '</div>' );
jQuery(this).after( '<div class="wc_error_tip">' + woocommerce_admin.i18n_decimal_input_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;
})
.bind( 'blur', function() {

View File

@ -1,3 +1,3 @@
/**
* WooCommerce Admin JS
*/jQuery(function(){jQuery(".wc_input_price[type=text]").bind("keyup change",function(){var e=jQuery(this).val(),t=e.replace(/[^0-9.]+/g,"");if(t.indexOf(".")!=-1){var n=t.split(".");n.length>2&&(t=n[0]+"."+n[1])}if(e!==t){jQuery(this).val(t);if(jQuery(this).parent().find(".wc_error_tip").size()==0){var r=jQuery(this).position();jQuery(this).after('<div class="wc_error_tip">'+woocommerce_admin.i18n_price_input_error+"</div>");jQuery(".wc_error_tip").css("left",r.left+jQuery(this).width()-jQuery(this).width()/2-jQuery(".wc_error_tip").width()/2).css("top",r.top+jQuery(this).height()).fadeIn("100")}}return this}).bind("blur",function(){jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()});return this});jQuery("body").click(function(){jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()})});jQuery(".tips, .help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200});jQuery(".wc_input_table.sortable tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")}});jQuery(".wc_input_table .remove_rows").click(function(){var e=jQuery(this).closest(".wc_input_table").find("tbody");if(e.find("tr.current").size()>0){$current=e.find("tr.current");$current.each(function(){jQuery(this).remove()})}return!1});var e=!1,t=!1,n=!1;jQuery(document).bind("keyup keydown",function(n){t=n.shiftKey;e=n.ctrlKey||n.metaKey});jQuery(".wc_input_table").on("focus click","input",function(r){$this_table=jQuery(this).closest("table");$this_row=jQuery(this).closest("tr");if(r.type=="focus"&&n!=$this_row.index()||r.type=="click"&&jQuery(this).is(":focus")){n=$this_row.index();if(!t&&!e){jQuery("tr",$this_table).removeClass("current").removeClass("last_selected");$this_row.addClass("current").addClass("last_selected")}else if(t){jQuery("tr",$this_table).removeClass("current");$this_row.addClass("selected_now").addClass("current");jQuery("tr.last_selected",$this_table).size()>0&&($this_row.index()>jQuery("tr.last_selected, $this_table").index()?jQuery("tr",$this_table).slice(jQuery("tr.last_selected",$this_table).index(),$this_row.index()).addClass("current"):jQuery("tr",$this_table).slice($this_row.index(),jQuery("tr.last_selected",$this_table).index()+1).addClass("current"));jQuery("tr",$this_table).removeClass("last_selected");$this_row.addClass("last_selected")}else{jQuery("tr",$this_table).removeClass("last_selected");e&&jQuery(this).closest("tr").is(".current")?$this_row.removeClass("current"):$this_row.addClass("current").addClass("last_selected")}jQuery("tr",$this_table).removeClass("selected_now")}}).on("blur","input",function(e){n=!1});jQuery("select.availability").change(function(){jQuery(this).val()=="all"?jQuery(this).closest("tr").next("tr").hide():jQuery(this).closest("tr").next("tr").show()}).change();jQuery("body").on("click",".show_order_items",function(){jQuery(this).closest("td").find("table").toggle();return!1});jQuery(".hide_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()});jQuery(".show_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()});jQuery("input#woocommerce_demo_store").change(function(){jQuery(this).is(":checked")?jQuery("#woocommerce_demo_store_notice").closest("tr").show():jQuery("#woocommerce_demo_store_notice").closest("tr").hide()}).change()});
*/jQuery(function(){jQuery(".wc_input_decimal[type=text]").each(function(){var e=jQuery(this).val(),t=e.replace(".",woocommerce_admin.locale_decimal_point);jQuery(this).val(t)});jQuery(".wc_input_decimal[type=text]").bind("keyup change",function(){var e=jQuery(this).val(),t=new RegExp("[^0-9%.\\"+woocommerce_admin.locale_decimal_point+"]+","gi"),n=e.replace(t,"");if(e!==n){jQuery(this).val(n);if(jQuery(this).parent().find(".wc_error_tip").size()==0){var r=jQuery(this).position();jQuery(this).after('<div class="wc_error_tip">'+woocommerce_admin.i18n_decimal_input_error+"</div>");jQuery(".wc_error_tip").css("left",r.left+jQuery(this).width()-jQuery(this).width()/2-jQuery(".wc_error_tip").width()/2).css("top",r.top+jQuery(this).height()).fadeIn("100")}}return this}).bind("blur",function(){jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()});return this});jQuery("body").click(function(){jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()})});jQuery(".tips, .help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200});jQuery(".wc_input_table.sortable tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")}});jQuery(".wc_input_table .remove_rows").click(function(){var e=jQuery(this).closest(".wc_input_table").find("tbody");if(e.find("tr.current").size()>0){$current=e.find("tr.current");$current.each(function(){jQuery(this).remove()})}return!1});var e=!1,t=!1,n=!1;jQuery(document).bind("keyup keydown",function(n){t=n.shiftKey;e=n.ctrlKey||n.metaKey});jQuery(".wc_input_table").on("focus click","input",function(r){$this_table=jQuery(this).closest("table");$this_row=jQuery(this).closest("tr");if(r.type=="focus"&&n!=$this_row.index()||r.type=="click"&&jQuery(this).is(":focus")){n=$this_row.index();if(!t&&!e){jQuery("tr",$this_table).removeClass("current").removeClass("last_selected");$this_row.addClass("current").addClass("last_selected")}else if(t){jQuery("tr",$this_table).removeClass("current");$this_row.addClass("selected_now").addClass("current");jQuery("tr.last_selected",$this_table).size()>0&&($this_row.index()>jQuery("tr.last_selected, $this_table").index()?jQuery("tr",$this_table).slice(jQuery("tr.last_selected",$this_table).index(),$this_row.index()).addClass("current"):jQuery("tr",$this_table).slice($this_row.index(),jQuery("tr.last_selected",$this_table).index()+1).addClass("current"));jQuery("tr",$this_table).removeClass("last_selected");$this_row.addClass("last_selected")}else{jQuery("tr",$this_table).removeClass("last_selected");e&&jQuery(this).closest("tr").is(".current")?$this_row.removeClass("current"):$this_row.addClass("current").addClass("last_selected")}jQuery("tr",$this_table).removeClass("selected_now")}}).on("blur","input",function(e){n=!1});jQuery("select.availability").change(function(){jQuery(this).val()=="all"?jQuery(this).closest("tr").next("tr").hide():jQuery(this).closest("tr").next("tr").show()}).change();jQuery("body").on("click",".show_order_items",function(){jQuery(this).closest("td").find("table").toggle();return!1});jQuery(".hide_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()});jQuery(".show_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()});jQuery("input#woocommerce_demo_store").change(function(){jQuery(this).is(":checked")?jQuery("#woocommerce_demo_store_notice").closest("tr").show():jQuery("#woocommerce_demo_store_notice").closest("tr").hide()}).change()});

View File

@ -65,7 +65,7 @@ jQuery(document).ready(function($) {
$thisbutton.addClass('added');
// View cart text
if ( $thisbutton.parent().find('.added_to_cart').size() == 0 )
if ( ! wc_add_to_cart_params.is_cart && $thisbutton.parent().find('.added_to_cart').size() == 0 )
$thisbutton.after( ' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart" title="' + wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>' );
// Replace fragments

View File

@ -1 +1 @@
jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity")};e("body").trigger("adding_to_cart",[t,n]);e.post(wc_add_to_cart_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");if(n.error&&n.product_url){window.location=n.product_url;return}if(wc_add_to_cart_params.cart_redirect_after_add=="yes"){window.location=wc_add_to_cart_params.cart_url;return}t.removeClass("loading");fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+wc_add_to_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.addClass("added");t.parent().find(".added_to_cart").size()==0&&t.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})});
jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity")};e("body").trigger("adding_to_cart",[t,n]);e.post(wc_add_to_cart_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");if(n.error&&n.product_url){window.location=n.product_url;return}if(wc_add_to_cart_params.cart_redirect_after_add=="yes"){window.location=wc_add_to_cart_params.cart_url;return}t.removeClass("loading");fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+wc_add_to_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.addClass("added");!wc_add_to_cart_params.is_cart&&t.parent().find(".added_to_cart").size()==0&&t.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})});

View File

@ -10,7 +10,7 @@ jQuery(document).ready(function($) {
$('ul.tabs li', $tabs_wrapper).removeClass('active');
$('div.panel', $tabs_wrapper).hide();
$('div' + $tab.attr('href')).show();
$('div' + $tab.attr('href'), $tabs_wrapper).show();
$tab.parent().addClass('active');
return false;
@ -54,4 +54,4 @@ jQuery(document).ready(function($) {
$(this).find(':submit').attr( 'disabled','disabled' );
});
});
});

View File

@ -1 +1 @@
jQuery(document).ready(function(e){e(".woocommerce-tabs .panel").hide();e(".woocommerce-tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce-tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href")).show();t.parent().addClass("active");return!1});e(".woocommerce-tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');e("body").on("click","#respond p.stars a",function(){var t=e(this),n=e(this).closest("#respond").find("#rating");n.val(t.text());t.siblings("a").removeClass("active");t.addClass("active");return!1}).on("click","#respond #submit",function(){var t=e(this).closest("#respond").find("#rating"),n=t.val();if(t.size()>0&&!n&&wc_single_product_params.review_rating_required=="yes"){alert(wc_single_product_params.i18n_required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})});
jQuery(document).ready(function(e){e(".woocommerce-tabs .panel").hide();e(".woocommerce-tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce-tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href"),n).show();t.parent().addClass("active");return!1});e(".woocommerce-tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');e("body").on("click","#respond p.stars a",function(){var t=e(this),n=e(this).closest("#respond").find("#rating");n.val(t.text());t.siblings("a").removeClass("active");t.addClass("active");return!1}).on("click","#respond #submit",function(){var t=e(this).closest("#respond").find("#rating"),n=t.val();if(t.size()>0&&!n&&wc_single_product_params.review_rating_required=="yes"){alert(wc_single_product_params.i18n_required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -263,22 +263,6 @@ abstract class WC_Settings_API {
return $html;
}
/**
* Wrapper for text inputs for prices.
*
* @access public
* @param mixed $key
* @param mixed $data
* @since 1.0.0
* @return string
*/
public function generate_price_html( $key, $data ) {
$data['type'] = 'text';
$data['class'] = isset( $data['class'] ) ? $data['class'] . ' wc_input_price' : 'wc_input_price';
return $this->generate_text_html( $key, $data );
}
/**
* Generate Password Input HTML.
*
@ -668,6 +652,11 @@ abstract class WC_Settings_API {
$field = $this->{'validate_text_field'}( $k );
$this->sanitized_fields[ $k ] = $field;
}
// Format values
if ( isset( $v['class'] ) && strstr( $v['class'], 'wc_input_decimal' ) ) {
$this->sanitized_fields[ $k ] = ( $this->sanitized_fields[ $k ] === '' ) ? '' : woocommerce_format_decimal( $this->sanitized_fields[ $k ], false );
}
}
}

View File

@ -98,8 +98,11 @@ class WC_Admin_Assets {
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'filesaver' );
$locale = localeconv();
$params = array(
'i18n_price_input_error' => __( 'Please enter your prices in decimal format without currency symbols.', 'woocommerce' ),
'i18n_decimal_input_error' => __( 'Please enter in decimal format without thousand separators and currency symbols.', 'woocommerce' ),
'locale_decimal_point' => isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.'
);
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );

View File

@ -59,7 +59,8 @@ class WC_Admin_Attributes {
// Auto-generate the label or slug if only one of both was provided
if ( ! $attribute_label ) {
$attribute_label = ucwords( $attribute_name );
} elseif ( ! $attribute_name ) {
}
if ( ! $attribute_name ) {
$attribute_name = woocommerce_sanitize_taxonomy_name( stripslashes( $attribute_label ) );
}
@ -198,11 +199,9 @@ class WC_Admin_Attributes {
}
}
// If an attribute was added, edited or deleted: clear cache and redirect
// If an attribute was added, edited or deleted: clear cache
if ( ! empty( $action_completed ) ) {
delete_transient( 'wc_attribute_taxonomies' );
wp_safe_redirect( get_admin_url() . 'edit.php?post_type=product&page=woocommerce_attributes' );
exit;
}
// Show admin interface

View File

@ -337,9 +337,10 @@ if ( class_exists( 'WP_Importer' ) ) {
/**
* Added to http_request_timeout filter to force timeout at 60 seconds during import
* @param int $val
* @return int 60
*/
function bump_request_timeout() {
function bump_request_timeout( $val ) {
return 60;
}
}

View File

@ -41,7 +41,7 @@ class WC_Meta_Box_Coupon_Data {
woocommerce_wp_select( array( 'id' => 'discount_type', 'label' => __( 'Discount type', 'woocommerce' ), 'options' => wc_get_coupon_types() ) );
// Amount
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'class' => 'wc_input_price' ) );
woocommerce_wp_text_input( array( 'id' => 'coupon_amount', 'label' => __( 'Coupon amount', 'woocommerce' ), 'placeholder' => '0.00', 'description' => __( 'Value of the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal' ) );
// Free Shipping
woocommerce_wp_checkbox( array( 'id' => 'free_shipping', 'label' => __( 'Enable free shipping', 'woocommerce' ), 'description' => sprintf(__( 'Check this box if the coupon grants free shipping. The <a href="%s">free shipping method</a> must be enabled with the "must use coupon" setting checked.', 'woocommerce' ), admin_url('admin.php?page=woocommerce_settings&tab=shipping&section=WC_Shipping_Free_Shipping')) ) );
@ -58,7 +58,7 @@ class WC_Meta_Box_Coupon_Data {
echo '</div><div class="options_group">';
// minimum spend
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum amount', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ), 'class' => 'wc_input_price' ) );
woocommerce_wp_text_input( array( 'id' => 'minimum_amount', 'label' => __( 'Minimum amount', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum subtotal needed to use the coupon.', 'woocommerce' ), 'class' => 'wc_input_decimal' ) );
echo '</div><div class="options_group">';
@ -145,6 +145,12 @@ class WC_Meta_Box_Coupon_Data {
'min' => '0'
) ) );
// Usage limit
woocommerce_wp_text_input( array( 'id' => 'usage_limit_per_user', 'label' => __( 'Usage limit per user', 'woocommerce' ), 'placeholder' => _x( 'Unlimited usage', 'placeholder', 'woocommerce' ), 'description' => __( 'How many times this coupon can be used by an invidual user. Uses billing email for guests, and user ID for logged in users.', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
'step' => '1',
'min' => '0'
) ) );
// Expiry date
woocommerce_wp_text_input( array( 'id' => 'expiry_date', 'label' => __( 'Expiry date', 'woocommerce' ), 'placeholder' => _x('Never expire', 'placeholder', 'woocommerce'), 'description' => __( 'The date this coupon will expire, <code>YYYY-MM-DD</code>.', 'woocommerce' ), 'class' => 'short date-picker', 'custom_attributes' => array( 'pattern' => "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" ) ) );
@ -180,16 +186,17 @@ class WC_Meta_Box_Coupon_Data {
WC_Admin_Meta_Boxes::add_error( __( 'Coupon code already exists - customers will use the latest coupon with this code.', 'woocommerce' ) );
// Add/Replace data to array
$type = woocommerce_clean( $_POST['discount_type'] );
$amount = woocommerce_clean( $_POST['coupon_amount'] );
$usage_limit = empty( $_POST['usage_limit'] ) ? '' : absint( $_POST['usage_limit'] );
$individual_use = isset( $_POST['individual_use'] ) ? 'yes' : 'no';
$expiry_date = woocommerce_clean( $_POST['expiry_date'] );
$apply_before_tax = isset( $_POST['apply_before_tax'] ) ? 'yes' : 'no';
$free_shipping = isset( $_POST['free_shipping'] ) ? 'yes' : 'no';
$exclude_sale_items = isset( $_POST['exclude_sale_items'] ) ? 'yes' : 'no';
$minimum_amount = woocommerce_clean( $_POST['minimum_amount'] );
$customer_email = array_filter( array_map( 'trim', explode( ',', woocommerce_clean( $_POST['customer_email'] ) ) ) );
$type = woocommerce_clean( $_POST['discount_type'] );
$amount = woocommerce_format_decimal( $_POST['coupon_amount'], false );
$usage_limit = empty( $_POST['usage_limit'] ) ? '' : absint( $_POST['usage_limit'] );
$usage_limit_per_user = empty( $_POST['usage_limit_per_user'] ) ? '' : absint( $_POST['usage_limit_per_user'] );
$individual_use = isset( $_POST['individual_use'] ) ? 'yes' : 'no';
$expiry_date = woocommerce_clean( $_POST['expiry_date'] );
$apply_before_tax = isset( $_POST['apply_before_tax'] ) ? 'yes' : 'no';
$free_shipping = isset( $_POST['free_shipping'] ) ? 'yes' : 'no';
$exclude_sale_items = isset( $_POST['exclude_sale_items'] ) ? 'yes' : 'no';
$minimum_amount = woocommerce_format_decimal( $_POST['minimum_amount'], false );
$customer_email = array_filter( array_map( 'trim', explode( ',', woocommerce_clean( $_POST['customer_email'] ) ) ) );
if ( isset( $_POST['product_ids'] ) ) {
$product_ids = implode( ',', array_filter( array_map( 'intval', (array) $_POST['product_ids'] ) ) );
@ -213,6 +220,7 @@ class WC_Meta_Box_Coupon_Data {
update_post_meta( $post_id, 'product_ids', $product_ids );
update_post_meta( $post_id, 'exclude_product_ids', $exclude_product_ids );
update_post_meta( $post_id, 'usage_limit', $usage_limit );
update_post_meta( $post_id, 'usage_limit_per_user', $usage_limit_per_user );
update_post_meta( $post_id, 'expiry_date', $expiry_date );
update_post_meta( $post_id, 'apply_before_tax', $apply_before_tax );
update_post_meta( $post_id, 'free_shipping', $free_shipping );

View File

@ -279,7 +279,7 @@ class WC_Meta_Box_Order_Data {
}
if ( apply_filters( 'woocommerce_enable_order_notes_field', get_option( 'woocommerce_enable_order_comments', 'yes' ) == 'yes' ) && $post->post_excerpt )
echo '<p><strong>' . __( 'Customer Note', 'woocommerce' ) . ':</strong> ' . esc_html( $post->post_excerpt ) . '</p>';
echo '<p><strong>' . __( 'Customer Note', 'woocommerce' ) . ':</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
echo '</div>';

View File

@ -134,26 +134,26 @@ class WC_Meta_Box_Order_Items {
if ( isset( $order_item_qty[ $item_id ] ) )
woocommerce_update_order_item_meta( $item_id, '_qty', apply_filters( 'woocommerce_stock_amount', $order_item_qty[ $item_id ] ) );
if ( isset( $item_tax_class[ $item_id ] ) )
woocommerce_update_order_item_meta( $item_id, '_tax_class', woocommerce_clean( $item_tax_class[ $item_id ] ) );
if ( isset( $order_item_tax_class[ $item_id ] ) )
woocommerce_update_order_item_meta( $item_id, '_tax_class', woocommerce_clean( $order_item_tax_class[ $item_id ] ) );
if ( isset( $line_subtotal[ $item_id ] ) ) {
woocommerce_update_order_item_meta( $item_id, '_line_subtotal', woocommerce_clean( $line_subtotal[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, '_line_subtotal', woocommerce_format_decimal( $line_subtotal[ $item_id ], false ) );
$subtotal += woocommerce_clean( $line_subtotal[ $item_id ] );
}
if ( isset( $line_subtotal_tax[ $item_id ] ) )
woocommerce_update_order_item_meta( $item_id, '_line_subtotal_tax', woocommerce_clean( $line_subtotal_tax[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, '_line_subtotal_tax', woocommerce_format_decimal( $line_subtotal_tax[ $item_id ], false ) );
if ( isset( $line_total[ $item_id ] ) ) {
woocommerce_update_order_item_meta( $item_id, '_line_total', woocommerce_clean( $line_total[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, '_line_total', woocommerce_format_decimal( $line_total[ $item_id ], false ) );
$total += woocommerce_clean( $line_total[ $item_id ] );
}
if ( isset( $line_tax[ $item_id ] ) )
woocommerce_update_order_item_meta( $item_id, '_line_tax', woocommerce_clean( $line_tax[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, '_line_tax', woocommerce_format_decimal( $line_tax[ $item_id ], false ) );
// Clear meta cache
wp_cache_delete( $item_id, 'order_item_meta' );
@ -179,6 +179,6 @@ class WC_Meta_Box_Order_Items {
}
// Update cart discount from item totals
update_post_meta( $post_id, '_cart_discount', woocommerce_format_total( $subtotal - $total ) );
update_post_meta( $post_id, '_cart_discount', woocommerce_format_decimal( $subtotal - $total, false ) );
}
}

View File

@ -111,14 +111,14 @@ class WC_Meta_Box_Order_Totals {
<div class="totals_group">
<h4><label for="_order_total"><?php _e( 'Order Discount', 'woocommerce' ); ?></label></h4>
<input type="number" step="any" min="0" id="_order_discount" name="_order_discount" placeholder="0.00" value="<?php
<input type="text" class="wc_input_decimal" id="_order_discount" name="_order_discount" placeholder="0.00" value="<?php
if ( isset( $data['_order_discount'][0] ) )
echo esc_attr( $data['_order_discount'][0] );
?>" />
</div>
<div class="totals_group">
<h4><label for="_order_total"><?php _e( 'Order Total', 'woocommerce' ); ?></label></h4>
<input type="number" step="any" min="0" id="_order_total" name="_order_total" placeholder="0.00" value="<?php
<input type="text" class="wc_input_decimal" id="_order_total" name="_order_total" placeholder="0.00" value="<?php
if ( isset( $data['_order_total'][0] ) )
echo esc_attr( $data['_order_total'][0] );
?>" />
@ -206,15 +206,15 @@ class WC_Meta_Box_Order_Totals {
woocommerce_update_order_item_meta( $new_id, 'compound', $compound );
if ( isset( $order_taxes_amount[ $item_id ][ $new_key ] ) ) {
woocommerce_update_order_item_meta( $new_id, 'tax_amount', woocommerce_clean( $order_taxes_amount[ $item_id ][ $new_key ] ) );
woocommerce_update_order_item_meta( $new_id, 'tax_amount', woocommerce_format_decimal( $order_taxes_amount[ $item_id ][ $new_key ], false ) );
$total_tax += woocommerce_clean( $order_taxes_amount[ $item_id ][ $new_key ] );
$total_tax += woocommerce_format_decimal( $order_taxes_amount[ $item_id ][ $new_key ], false );
}
if ( isset( $order_taxes_shipping_amount[ $item_id ][ $new_key ] ) ) {
woocommerce_update_order_item_meta( $new_id, 'shipping_tax_amount', woocommerce_clean( $order_taxes_shipping_amount[ $item_id ][ $new_key ] ) );
woocommerce_update_order_item_meta( $new_id, 'shipping_tax_amount', woocommerce_format_decimal( $order_taxes_shipping_amount[ $item_id ][ $new_key ], false ) );
$total_shipping_tax += woocommerce_clean( $order_taxes_shipping_amount[ $item_id ][ $new_key ] );
$total_shipping_tax += woocommerce_format_decimal( $order_taxes_shipping_amount[ $item_id ][ $new_key ], false );
}
}
}
@ -254,25 +254,25 @@ class WC_Meta_Box_Order_Totals {
woocommerce_update_order_item_meta( $item_id, 'compound', $compound );
if ( isset( $order_taxes_amount[ $item_id ] ) ) {
woocommerce_update_order_item_meta( $item_id, 'tax_amount', woocommerce_clean( $order_taxes_amount[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, 'tax_amount', woocommerce_format_decimal( $order_taxes_amount[ $item_id ], false ) );
$total_tax += woocommerce_clean( $order_taxes_amount[ $item_id ] );
$total_tax += woocommerce_format_decimal( $order_taxes_amount[ $item_id ], false );
}
if ( isset( $order_taxes_shipping_amount[ $item_id ] ) ) {
woocommerce_update_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_clean( $order_taxes_shipping_amount[ $item_id ] ) );
woocommerce_update_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_format_decimal( $order_taxes_shipping_amount[ $item_id ], false ) );
$total_shipping_tax += woocommerce_clean( $order_taxes_shipping_amount[ $item_id ] );
$total_shipping_tax += woocommerce_format_decimal( $order_taxes_shipping_amount[ $item_id ], false );
}
}
}
}
// Update totals
update_post_meta( $post_id, '_order_tax', woocommerce_format_total( $total_tax ) );
update_post_meta( $post_id, '_order_shipping_tax', woocommerce_format_total( $total_shipping_tax ) );
update_post_meta( $post_id, '_order_discount', woocommerce_format_total( woocommerce_clean( $_POST['_order_discount'] ) ) );
update_post_meta( $post_id, '_order_total', woocommerce_format_total( woocommerce_clean( $_POST['_order_total'] ) ) );
update_post_meta( $post_id, '_order_tax', woocommerce_format_decimal( $total_tax, false ) );
update_post_meta( $post_id, '_order_shipping_tax', woocommerce_format_decimal( $total_shipping_tax, false ) );
update_post_meta( $post_id, '_order_discount', woocommerce_format_decimal( $_POST['_order_discount'], false ) );
update_post_meta( $post_id, '_order_total', woocommerce_format_decimal( $_POST['_order_total'], false ) );
// Shipping Rows
$order_shipping = 0;
@ -291,7 +291,7 @@ class WC_Meta_Box_Order_Totals {
foreach ( $value as $new_key => $new_value ) {
$method_id = woocommerce_clean( $shipping_method[ $item_id ][ $new_key ] );
$method_title = woocommerce_clean( $shipping_method_title[ $item_id ][ $new_key ] );
$cost = woocommerce_format_total( woocommerce_clean( $shipping_cost[ $item_id ][ $new_key ] ) );
$cost = woocommerce_format_decimal( $shipping_cost[ $item_id ][ $new_key ], false );
$new_id = woocommerce_add_order_item( $post_id, array(
'order_item_name' => $method_title,
@ -311,7 +311,7 @@ class WC_Meta_Box_Order_Totals {
$item_id = absint( $item_id );
$method_id = woocommerce_clean( $shipping_method[ $item_id ] );
$method_title = woocommerce_clean( $shipping_method_title[ $item_id ] );
$cost = woocommerce_format_total( woocommerce_clean( $shipping_cost[ $item_id ] ) );
$cost = woocommerce_format_decimal( $shipping_cost[ $item_id ], false );
$wpdb->update(
$wpdb->prefix . "woocommerce_order_items",
@ -339,6 +339,6 @@ class WC_Meta_Box_Order_Totals {
delete_post_meta( $post_id, '_shipping_method' );
delete_post_meta( $post_id, '_shipping_method_title' );
update_post_meta( $post_id, '_order_shipping', woocommerce_format_total( $order_shipping ) );
update_post_meta( $post_id, '_order_shipping', woocommerce_format_decimal( $order_shipping, false ) );
}
}

View File

@ -153,10 +153,10 @@ class WC_Meta_Box_Product_Data {
echo '<div class="options_group pricing show_if_simple show_if_external">';
// Price
woocommerce_wp_text_input( array( 'id' => '_regular_price', 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')' ) );
woocommerce_wp_text_input( array( 'id' => '_regular_price', 'class' => 'wc_input_decimal short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')' ) );
// Special Price
woocommerce_wp_text_input( array( 'id' => '_sale_price', 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>' ) );
woocommerce_wp_text_input( array( 'id' => '_sale_price', 'class' => 'wc_input_decimal short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')', 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>' ) );
// Special Price date range
$sale_price_dates_from = ( $date = get_post_meta( $thepostid, '_sale_price_dates_from', true ) ) ? date_i18n( 'Y-m-d', $date ) : '';
@ -339,31 +339,21 @@ class WC_Meta_Box_Product_Data {
echo '<div class="options_group">';
// Weight
if ( wc_product_weight_enabled() ) :
woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00', 'description' => __( 'Weight in decimal form', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array(
'step' => 'any',
'min' => '0'
) ) );
else:
echo '<input type="hidden" name="_weight" value="' . esc_attr( get_post_meta( $thepostid, '_weight', true ) ) . '" />';
endif;
if ( wc_product_weight_enabled() )
woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00', 'description' => __( 'Weight in decimal form', 'woocommerce' ), 'type' => 'text', 'class' => 'wc_input_decimal short' ) );
// Size fields
if ( wc_product_dimensions_enabled() ) :
if ( wc_product_dimensions_enabled() ) {
?><p class="form-field dimensions_field">
<label for="product_length"><?php echo __( 'Dimensions', 'woocommerce' ) . ' (' . get_option( 'woocommerce_dimension_unit' ) . ')'; ?></label>
<span class="wrap">
<input id="product_length" placeholder="<?php _e( 'Length', 'woocommerce' ); ?>" class="input-text" size="6" type="number" name="_length" value="<?php echo esc_attr( get_post_meta( $thepostid, '_length', true ) ); ?>" step="any" min="0" />
<input placeholder="<?php _e( 'Width', 'woocommerce' ); ?>" class="input-text" size="6" type="number" name="_width" value="<?php echo esc_attr( get_post_meta( $thepostid, '_width', true ) ); ?>" step="any" min="0" />
<input placeholder="<?php _e( 'Height', 'woocommerce' ); ?>" class="input-text last" size="6" type="number" name="_height" value="<?php echo esc_attr( get_post_meta( $thepostid, '_height', true ) ); ?>" step="any" min="0" />
<input id="product_length" placeholder="<?php _e( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php echo esc_attr( get_post_meta( $thepostid, '_length', true ) ); ?>" />
<input placeholder="<?php _e( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php echo esc_attr( get_post_meta( $thepostid, '_width', true ) ); ?>" />
<input placeholder="<?php _e( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php echo esc_attr( get_post_meta( $thepostid, '_height', true ) ); ?>" />
</span>
<span class="description"><?php _e( 'LxWxH in decimal form', 'woocommerce' ); ?></span>
</p><?php
else:
echo '<input type="hidden" name="_length" value="' . esc_attr( get_post_meta( $thepostid, '_length', true ) ) . '" />';
echo '<input type="hidden" name="_width" value="' . esc_attr( get_post_meta( $thepostid, '_width', true ) ) . '" />';
echo '<input type="hidden" name="_height" value="' . esc_attr( get_post_meta( $thepostid, '_height', true ) ) . '" />';
endif;
}
do_action( 'woocommerce_product_options_dimensions' );
@ -941,8 +931,10 @@ class WC_Meta_Box_Product_Data {
update_post_meta( $post_id, '_virtual', $is_virtual );
// Update post meta
if ( isset( $_POST['_regular_price'] ) ) update_post_meta( $post_id, '_regular_price', stripslashes( $_POST['_regular_price'] ) );
if ( isset( $_POST['_sale_price'] ) ) update_post_meta( $post_id, '_sale_price', stripslashes( $_POST['_sale_price'] ) );
if ( isset( $_POST['_regular_price'] ) )
update_post_meta( $post_id, '_regular_price', ( $_POST['_regular_price'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_regular_price'], false ) );
if ( isset( $_POST['_sale_price'] ) )
update_post_meta( $post_id, '_sale_price', ( $_POST['_sale_price'] === '' ? '' : woocommerce_format_decimal( $_POST['_sale_price'], false ) ) );
if ( isset( $_POST['_tax_status'] ) ) update_post_meta( $post_id, '_tax_status', stripslashes( $_POST['_tax_status'] ) );
if ( isset( $_POST['_tax_class'] ) ) update_post_meta( $post_id, '_tax_class', stripslashes( $_POST['_tax_class'] ) );
if ( isset( $_POST['_visibility'] ) ) update_post_meta( $post_id, '_visibility', stripslashes( $_POST['_visibility'] ) );
@ -951,10 +943,19 @@ class WC_Meta_Box_Product_Data {
// Dimensions
if ( $is_virtual == 'no' ) {
update_post_meta( $post_id, '_weight', stripslashes( $_POST['_weight'] ) );
update_post_meta( $post_id, '_length', stripslashes( $_POST['_length'] ) );
update_post_meta( $post_id, '_width', stripslashes( $_POST['_width'] ) );
update_post_meta( $post_id, '_height', stripslashes( $_POST['_height'] ) );
if ( isset( $_POST['_weight'] ) )
update_post_meta( $post_id, '_weight', ( $_POST['_weight'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_weight'], false ) );
if ( isset( $_POST['_length'] ) )
update_post_meta( $post_id, '_length', ( $_POST['_length'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_length'], false ) );
if ( isset( $_POST['_width'] ) )
update_post_meta( $post_id, '_width', ( $_POST['_width'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_width'], false ) );
if ( isset( $_POST['_height'] ) )
update_post_meta( $post_id, '_height', ( $_POST['_height'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_height'], false ) );
} else {
update_post_meta( $post_id, '_weight', '' );
update_post_meta( $post_id, '_length', '' );
@ -1116,16 +1117,16 @@ class WC_Meta_Box_Product_Data {
update_post_meta( $post_id, '_sale_price_dates_from', strtotime( 'NOW', current_time( 'timestamp' ) ) );
// Update price if on sale
if ( $_POST['_sale_price'] != '' && $date_to == '' && $date_from == '' )
update_post_meta( $post_id, '_price', stripslashes( $_POST['_sale_price'] ) );
if ( $_POST['_sale_price'] !== '' && $date_to == '' && $date_from == '' )
update_post_meta( $post_id, '_price', woocommerce_format_decimal( $_POST['_sale_price'], false ) );
else
update_post_meta( $post_id, '_price', stripslashes( $_POST['_regular_price'] ) );
update_post_meta( $post_id, '_price', ( $_POST['_regular_price'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_regular_price'], false ) );
if ( $_POST['_sale_price'] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) )
update_post_meta( $post_id, '_price', stripslashes($_POST['_sale_price']) );
if ( $_POST['_sale_price'] !== '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) )
update_post_meta( $post_id, '_price', woocommerce_format_decimal( $_POST['_sale_price'], false ) );
if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
update_post_meta( $post_id, '_price', stripslashes($_POST['_regular_price']) );
update_post_meta( $post_id, '_price', ( $_POST['_regular_price'] === '' ) ? '' : woocommerce_format_decimal( $_POST['_regular_price'], false ) );
update_post_meta( $post_id, '_sale_price_dates_from', '');
update_post_meta( $post_id, '_sale_price_dates_to', '');
}
@ -1382,20 +1383,25 @@ class WC_Meta_Box_Product_Data {
// Update post meta
update_post_meta( $variation_id, '_sku', woocommerce_clean( $variable_sku[ $i ] ) );
update_post_meta( $variation_id, '_weight', woocommerce_clean( $variable_weight[ $i ] ) );
update_post_meta( $variation_id, '_length', woocommerce_clean( $variable_length[ $i ] ) );
update_post_meta( $variation_id, '_width', woocommerce_clean( $variable_width[ $i ] ) );
update_post_meta( $variation_id, '_height', woocommerce_clean( $variable_height[ $i ] ) );
update_post_meta( $variation_id, '_thumbnail_id', absint( $upload_image_id[ $i ] ) );
update_post_meta( $variation_id, '_virtual', woocommerce_clean( $is_virtual ) );
update_post_meta( $variation_id, '_downloadable', woocommerce_clean( $is_downloadable ) );
if ( isset( $variable_weight[ $i ] ) )
update_post_meta( $variation_id, '_weight', ( $variable_weight[ $i ] === '' ) ? '' : woocommerce_format_decimal( $variable_weight[ $i ], false ) );
if ( isset( $variable_length[ $i ] ) )
update_post_meta( $variation_id, '_length', ( $variable_length[ $i ] === '' ) ? '' : woocommerce_format_decimal( $variable_length[ $i ], false ) );
if ( isset( $variable_width[ $i ] ) )
update_post_meta( $variation_id, '_width', ( $variable_width[ $i ] === '' ) ? '' : woocommerce_format_decimal( $variable_width[ $i ], false ) );
if ( isset( $variable_height[ $i ] ) )
update_post_meta( $variation_id, '_height', ( $variable_height[ $i ] === '' ) ? '' : woocommerce_format_decimal( $variable_height[ $i ], false ) );
// Stock handling
wc_update_product_stock( $variation_id, woocommerce_clean( $variable_stock[ $i ] ) );
// Price handling
$regular_price = woocommerce_clean( $variable_regular_price[ $i ] );
$sale_price = woocommerce_clean( $variable_sale_price[ $i ] );
$regular_price = woocommerce_format_decimal( $variable_regular_price[ $i ], false );
$sale_price = ( $variable_sale_price[ $i ] === '' ? '' : woocommerce_format_decimal( $variable_sale_price[ $i ], false ) );
$date_from = woocommerce_clean( $variable_sale_price_dates_from[ $i ] );
$date_to = woocommerce_clean( $variable_sale_price_dates_to[ $i ] );

View File

@ -59,7 +59,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( isset( $item['line_total'] ) ) echo woocommerce_price( $item['line_tax'] ); ?>
</div>
<div class="edit" style="display:none">
<label><?php _e( 'Total', 'woocommerce' ); ?>: <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total" /></label>
<label><?php _e( 'Total', 'woocommerce' ); ?>: <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total wc_input_decimal" /></label>
</div>
</td>
@ -70,7 +70,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( isset( $item['line_tax'] ) ) echo woocommerce_price( $item['line_tax'] ); ?>
</div>
<div class="edit" style="display:none">
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax" />
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax wc_input_decimal" />
</div>
</td>

View File

@ -114,37 +114,35 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php do_action( 'woocommerce_admin_order_item_values', $_product, $item, absint( $item_id ) ); ?>
<?php if ( get_option( 'woocommerce_calc_taxes' ) == 'yes' ) : ?>
<?php if ( get_option( 'woocommerce_calc_taxes' ) == 'yes' ) :
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
$classes_options = array();
$classes_options[''] = __( 'Standard', 'woocommerce' );
<td class="tax_class" width="1%">
<div class="view">
<?php
$item_value = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : '';
echo $item_value ? $item_value : __( 'Standard', 'woocommerce' );
?>
</div>
<div class="edit" style="display:none">
<select class="tax_class" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" title="<?php _e( 'Tax class', 'woocommerce' ); ?>">
if ( $tax_classes )
foreach ( $tax_classes as $class )
$classes_options[ sanitize_title( $class ) ] = $class;
?>
<td class="tax_class" width="1%">
<div class="view">
<?php
$item_value = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : '';
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('woocommerce_tax_classes' ) ) ) );
$classes_options = array();
$classes_options[''] = __( 'Standard', 'woocommerce' );
if ( $tax_classes )
foreach ( $tax_classes as $class )
$classes_options[ sanitize_title( $class ) ] = $class;
foreach ( $classes_options as $value => $name )
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $item_value, false ) . '>' . esc_html( $name ) . '</option>';
$item_value = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : '';
echo $classes_options[ $item_value ];
?>
</select>
</div>
</td>
</div>
<div class="edit" style="display:none">
<select class="tax_class" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" title="<?php _e( 'Tax class', 'woocommerce' ); ?>">
<?php
$item_value = isset( $item['tax_class'] ) ? sanitize_title( $item['tax_class'] ) : '';
<?php endif; ?>
foreach ( $classes_options as $value => $name )
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $item_value, false ) . '>' . esc_html( $name ) . '</option>';
?>
</select>
</div>
</td>
<?php
endif; ?>
<td class="quantity" width="1%">
<div class="view">
@ -166,9 +164,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
</div>
<div class="edit" style="display:none">
<span class="subtotal"><label><?php _e( 'Subtotal', 'woocommerce' ); ?>: <a class="tips" data-tip="<?php _e( 'Before pre-tax discounts.', 'woocommerce' ); ?>" href="#">[?]</a> <input type="number" step="any" min="0" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal'] ) ) echo esc_attr( $item['line_subtotal'] ); ?>" class="line_subtotal" /></label></span>
<span class="subtotal"><label><?php _e( 'Subtotal', 'woocommerce' ); ?>: <a class="tips" data-tip="<?php _e( 'Before pre-tax discounts.', 'woocommerce' ); ?>" href="#">[?]</a> <input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal'] ) ) echo esc_attr( $item['line_subtotal'] ); ?>" class="line_subtotal wc_input_decimal" /></label></span>
<label><?php _e( 'Total', 'woocommerce' ); ?>: <a class="tips" data-tip="<?php _e( 'After pre-tax discounts.', 'woocommerce' ); ?>" href="#">[?]</a> <input type="number" step="any" min="0" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total" /></label>
<label><?php _e( 'Total', 'woocommerce' ); ?>: <a class="tips" data-tip="<?php _e( 'After pre-tax discounts.', 'woocommerce' ); ?>" href="#">[?]</a> <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_total'] ) ) echo esc_attr( $item['line_total'] ); ?>" class="line_total wc_input_decimal" /></label>
</div>
</td>
@ -185,9 +183,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
</div>
<div class="edit" style="display:none">
<span class="subtotal"><input type="number" step="any" min="0" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal_tax'] ) ) echo esc_attr( $item['line_subtotal_tax'] ); ?>" class="line_subtotal_tax" /></span>
<span class="subtotal"><input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_subtotal_tax'] ) ) echo esc_attr( $item['line_subtotal_tax'] ); ?>" class="line_subtotal_tax wc_input_decimal" /></span>
<input type="number" step="any" min="0" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax" />
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>]" placeholder="0.00" value="<?php if ( isset( $item['line_tax'] ) ) echo esc_attr( $item['line_tax'] ); ?>" class="line_tax wc_input_decimal" />
</div>
</td>

View File

@ -36,7 +36,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
</select>
</p>
<p class="last">
<input type="number" step="any" min="0" class="shipping_cost" name="shipping_cost[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="<?php _e( '0.00', 'woocommerce' ); ?>" value="<?php echo esc_attr( $shipping_cost ); ?>" class="first" />
<input type="text" class="shipping_cost wc_input_decimal" name="shipping_cost[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="<?php _e( '0.00', 'woocommerce' ); ?>" value="<?php echo esc_attr( $shipping_cost ); ?>" />
</p>
<a href="#" class="delete_total_row">&times;</a>
<div class="clear"></div>

View File

@ -15,11 +15,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
</p>
<p class="first">
<label><?php _e( 'Sales Tax', 'woocommerce' ) ?></label>
<input type="number" step="any" min="0" class="order_taxes_amount" name="order_taxes_amount[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="0.00" value="<?php if ( isset( $item['tax_amount'] ) ) echo esc_attr( $item['tax_amount'] ); ?>" />
<input type="text" class="order_taxes_amount wc_input_decimal" name="order_taxes_amount[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="0.00" value="<?php if ( isset( $item['tax_amount'] ) ) echo esc_attr( $item['tax_amount'] ); ?>" />
</p>
<p class="last">
<label><?php _e( 'Shipping Tax', 'woocommerce' ) ?></label>
<input type="number" step="any" min="0" class="order_taxes_shipping_amount" name="order_taxes_shipping_amount[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="0.00" value="<?php if ( isset( $item['shipping_tax_amount'] ) ) echo esc_attr( $item['shipping_tax_amount'] ); ?>" />
<input type="text" class="order_taxes_shipping_amount wc_input_decimal" name="order_taxes_shipping_amount[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="0.00" value="<?php if ( isset( $item['shipping_tax_amount'] ) ) echo esc_attr( $item['shipping_tax_amount'] ); ?>" />
</p>
<a href="#" class="delete_total_row">&times;</a>
<div class="clear"></div>

View File

@ -70,11 +70,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<tr class="variable_pricing">
<td>
<label><?php echo __( 'Regular Price:', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')'; ?></label>
<input type="text" size="5" name="variable_regular_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_regular_price ) ) echo esc_attr( $_regular_price ); ?>" class="wc_input_price" placeholder="<?php _e( 'Variation price (required)', 'woocommerce' ); ?>" />
<input type="text" size="5" name="variable_regular_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_regular_price ) ) echo esc_attr( $_regular_price ); ?>" class="wc_input_decimal" placeholder="<?php _e( 'Variation price (required)', 'woocommerce' ); ?>" />
</td>
<td>
<label><?php echo __( 'Sale Price:', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol().')'; ?> <a href="#" class="sale_schedule"><?php _e( 'Schedule', 'woocommerce' ); ?></a><a href="#" class="cancel_sale_schedule" style="display:none"><?php _e( 'Cancel schedule', 'woocommerce' ); ?></a></label>
<input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_sale_price ) ) echo esc_attr( $_sale_price ); ?>" class="wc_input_price" />
<input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_sale_price ) ) echo esc_attr( $_sale_price ); ?>" class="wc_input_decimal" />
</td>
</tr>
@ -94,7 +94,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( wc_product_weight_enabled() ) : ?>
<td class="hide_if_variation_virtual">
<label><?php _e( 'Weight', 'woocommerce' ) . ' (' . esc_html( get_option( 'woocommerce_weight_unit' ) ) . '):'; ?> <a class="tips" data-tip="<?php _e( 'Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce' ); ?>" href="#">[?]</a></label>
<input type="number" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" step="any" min="0" />
<input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" class="wc_input_decimal" />
</td>
<?php else : ?>
<td>&nbsp;</td>
@ -102,9 +102,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( wc_product_dimensions_enabled() ) : ?>
<td class="dimensions_field hide_if_variation_virtual">
<label for"product_length"><?php echo __( 'Dimensions (L&times;W&times;H)', 'woocommerce' ); ?></label>
<input id="product_length" class="input-text" size="6" type="number" step="any" min="0" name="variable_length[<?php echo $loop; ?>]" value="<?php if ( isset( $_length ) ) echo esc_attr( $_length ); ?>" placeholder="<?php echo esc_attr( $parent_data['length'] ); ?>" />
<input class="input-text" size="6" type="number" step="any" min="0" name="variable_width[<?php echo $loop; ?>]" value="<?php if ( isset( $_width ) ) echo esc_attr( $_width ); ?>" placeholder="<?php echo esc_attr( $parent_data['width'] ); ?>" />
<input class="input-text last" size="6" type="number" step="any" min="0" name="variable_height[<?php echo $loop; ?>]" value="<?php if ( isset( $_height ) ) echo esc_attr( $_height ); ?>" placeholder="<?php echo esc_attr( $parent_data['height'] ); ?>" />
<input id="product_length" class="input-text wc_input_decimal" size="6" type="text" name="variable_length[<?php echo $loop; ?>]" value="<?php if ( isset( $_length ) ) echo esc_attr( $_length ); ?>" placeholder="<?php echo esc_attr( $parent_data['length'] ); ?>" />
<input class="input-text wc_input_decimal" size="6" type="text" name="variable_width[<?php echo $loop; ?>]" value="<?php if ( isset( $_width ) ) echo esc_attr( $_width ); ?>" placeholder="<?php echo esc_attr( $parent_data['width'] ); ?>" />
<input class="input-text wc_input_decimal last" size="6" type="text" name="variable_height[<?php echo $loop; ?>]" value="<?php if ( isset( $_height ) ) echo esc_attr( $_height ); ?>" placeholder="<?php echo esc_attr( $parent_data['height'] ); ?>" />
</td>
<?php else : ?>
<td>&nbsp;</td>

View File

@ -191,6 +191,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
* @return void
*/
public function shipping_methods_setting() {
$default_shipping_method = esc_attr( get_option('woocommerce_default_shipping_method') );
?>
<tr valign="top">
<th scope="row" class="titledesc"><?php _e( 'Shipping Methods', 'woocommerce' ) ?></th>
@ -206,18 +207,17 @@ class WC_Settings_Shipping extends WC_Settings_Page {
</tr>
</thead>
<tfoot>
<th width="1%" class="default">
<input type="radio" name="default_shipping_method" value="" <?php checked( $default_shipping_method, '' ); ?> />
</th>
<th><?php _e( 'No default', 'woocommerce' ); ?></th>
<th colspan="3"><span class="description"><?php _e( 'Drag and drop the above shipping methods to control their display order.', 'woocommerce' ); ?></span></th>
</foot>
<tr>
<th width="1%" class="default">
<input type="radio" name="default_shipping_method" value="" <?php checked( $default_shipping_method, '' ); ?> />
</th>
<th><?php _e( 'No default', 'woocommerce' ); ?></th>
<th colspan="3"><span class="description"><?php _e( 'Drag and drop the above shipping methods to control their display order.', 'woocommerce' ); ?></span></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ( WC()->shipping->load_shipping_methods() as $key => $method ) {
$default_shipping_method = esc_attr( get_option('woocommerce_default_shipping_method') );
echo '<tr>
<td width="1%" class="default">
<input type="radio" name="default_shipping_method" value="' . $method->id . '" ' . checked( $default_shipping_method, $method->id, false ) . ' />
@ -268,8 +268,6 @@ class WC_Settings_Shipping extends WC_Settings_Page {
$current_section_class = new $current_section();
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section_class->id );
WC()->shipping()->init();
}
}
}

View File

@ -50,6 +50,15 @@
<td><?php _e( 'MySQL Version','woocommerce' ); ?>:</td>
<td><?php if ( function_exists( 'mysql_get_server_info' ) ) echo esc_html( mysql_get_server_info() ); ?></td>
</tr>
<tr>
<td><?php _e( 'PHP Locale','woocommerce' ); ?>:</td>
<td><?php
$locale = localeconv();
foreach ( $locale as $key => $val )
if ( is_string( $val ) )
echo $key . ': ' . $val . '</br>';
?></td>
</tr>
<tr>
<td><?php _e( 'WP Memory Limit','woocommerce' ); ?>:</td>
<td><?php

View File

@ -393,6 +393,10 @@ class WC_Cart {
/**
* Check for user coupons (now that we have billing email). If a coupon is invalid, add an error.
*
* Checks two types of coupons:
* 1. Where a list of customer emails are set (limits coupon usage to those defined)
* 2. Where a usage_limit_per_user is set (limits coupon usage to a number based on user ID and email)
*
* @access public
* @param array $posted
*/
@ -401,26 +405,55 @@ class WC_Cart {
foreach ( $this->applied_coupons as $key => $code ) {
$coupon = new WC_Coupon( $code );
if ( $coupon->is_valid() && is_array( $coupon->customer_email ) && sizeof( $coupon->customer_email ) > 0 ) {
if ( $coupon->is_valid() ) {
$coupon->customer_email = array_map( 'sanitize_email', $coupon->customer_email );
// Limit to defined email addresses
if ( is_array( $coupon->customer_email ) && sizeof( $coupon->customer_email ) > 0 ) {
$coupon->customer_email = array_map( 'sanitize_email', $coupon->customer_email );
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email;
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email;
}
$check_emails[] = $posted['billing_email'];
$check_emails = array_map( 'sanitize_email', array_map( 'strtolower', $check_emails ) );
if ( 0 == sizeof( array_intersect( $check_emails, $coupon->customer_email ) ) ) {
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
// Remove the coupon
unset( $this->applied_coupons[ $key ] );
WC()->session->set( 'coupon_codes', $this->applied_coupons );
WC()->session->set( 'refresh_totals', true );
}
}
$check_emails[] = $posted['billing_email'];
$check_emails = array_map( 'sanitize_email', array_map( 'strtolower', $check_emails ) );
// Usage limits per user - check against billing and user email and user ID
if ( $coupon->usage_limit_per_user > 0 ) {
$used_by = get_post_meta( $this->id, '_used_by' );
if ( 0 == sizeof( array_intersect( $check_emails, $coupon->customer_email ) ) ) {
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email;
}
$check_emails[] = $posted['billing_email'];
$check_emails = array_map( 'sanitize_email', array_map( 'strtolower', $check_emails ) );
// Remove the coupon
unset( $this->applied_coupons[ $key ] );
$usage_count = sizeof( array_keys( $used_by, get_current_user_id() ) );
WC()->session->set( 'coupon_codes', $this->applied_coupons );
WC()->session->set( 'refresh_totals', true );
foreach ( $check_emails as $check_email )
$usage_count = $usage_count + sizeof( array_keys( $used_by, $check_email ) );
if ( $usage_count >= $coupon->usage_limit_per_user ) {
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_USAGE_LIMIT_REACHED );
// Remove the coupon
unset( $this->applied_coupons[ $key ] );
WC()->session->set( 'coupon_codes', $this->applied_coupons );
WC()->session->set( 'refresh_totals', true );
}
}
}
}
@ -748,7 +781,8 @@ class WC_Cart {
$tax_totals[ $code ] = new stdClass();
$tax_totals[ $code ]->amount = 0;
}
$tax_totals[ $code ]->tax_rate_id = $key;
$tax_totals[ $code ]->is_compound = $this->tax->is_compound( $key );
$tax_totals[ $code ]->label = $this->tax->get_rate_label( $key );
$tax_totals[ $code ]->amount += $tax;
@ -772,9 +806,10 @@ class WC_Cart {
*/
public function find_product_in_cart( $cart_id = false ) {
if ( $cart_id !== false )
foreach ( $this->cart_contents as $cart_item_key => $cart_item )
if ( $cart_item_key == $cart_id )
return $cart_item_key;
if( is_array( $this->cart_contents ) )
foreach ( $this->cart_contents as $cart_item_key => $cart_item )
if ( $cart_item_key == $cart_id )
return $cart_item_key;
}
/**
@ -871,7 +906,7 @@ class WC_Cart {
// If its greater than 0, its already in the cart
if ( $in_cart_quantity > 0 ) {
wc_add_error( sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __( 'View Cart &rarr;', 'woocommerce' ), __( 'You already have this item in your cart.', 'woocommerce' ) ) );
wc_add_error( sprintf( '<a href="%s" class="button">%s</a> %s', get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart &rarr;', 'woocommerce' ), sprintf( __( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), $product_data->get_title() ) ) );
return false;
}
}
@ -2327,4 +2362,4 @@ class WC_Cart {
}
return apply_filters( 'woocommerce_cart_total_discount', $total_discount, $this );
}
}
}

View File

@ -226,7 +226,7 @@ class WC_Checkout {
foreach ( $this->checkout_fields['billing'] as $key => $field ) {
update_post_meta( $order_id, '_' . $key, $this->posted[ $key ] );
if ( $this->customer_id )
if ( $this->customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) )
update_user_meta( $this->customer_id, $key, $this->posted[ $key ] );
}
@ -245,7 +245,7 @@ class WC_Checkout {
}
// User
if ( $postvalue && $this->customer_id )
if ( $postvalue && $this->customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) )
update_user_meta( $this->customer_id, $key, $postvalue );
}
}
@ -339,8 +339,8 @@ class WC_Checkout {
woocommerce_add_order_item_meta( $item_id, 'rate_id', $key );
woocommerce_add_order_item_meta( $item_id, 'label', $woocommerce->cart->tax->get_rate_label( $key ) );
woocommerce_add_order_item_meta( $item_id, 'compound', absint( $woocommerce->cart->tax->is_compound( $key ) ? 1 : 0 ) );
woocommerce_add_order_item_meta( $item_id, 'tax_amount', woocommerce_clean( isset( $woocommerce->cart->taxes[ $key ] ) ? $woocommerce->cart->taxes[ $key ] : 0 ) );
woocommerce_add_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_clean( isset( $woocommerce->cart->shipping_taxes[ $key ] ) ? $woocommerce->cart->shipping_taxes[ $key ] : 0 ) );
woocommerce_add_order_item_meta( $item_id, 'tax_amount', woocommerce_format_decimal( isset( $woocommerce->cart->taxes[ $key ] ) ? $woocommerce->cart->taxes[ $key ] : 0 ), false );
woocommerce_add_order_item_meta( $item_id, 'shipping_tax_amount', woocommerce_format_decimal( isset( $woocommerce->cart->shipping_taxes[ $key ] ) ? $woocommerce->cart->shipping_taxes[ $key ] : 0 ), false );
}
}
@ -364,12 +364,13 @@ class WC_Checkout {
update_post_meta( $order_id, '_payment_method', $this->payment_method->id );
update_post_meta( $order_id, '_payment_method_title', $this->payment_method->get_title() );
}
update_post_meta( $order_id, '_order_shipping', woocommerce_format_total( $woocommerce->cart->shipping_total ) );
update_post_meta( $order_id, '_order_discount', woocommerce_format_total( $woocommerce->cart->get_order_discount_total() ) );
update_post_meta( $order_id, '_cart_discount', woocommerce_format_total( $woocommerce->cart->get_cart_discount_total() ) );
update_post_meta( $order_id, '_order_tax', woocommerce_clean( $woocommerce->cart->tax_total ) );
update_post_meta( $order_id, '_order_shipping_tax', woocommerce_clean( $woocommerce->cart->shipping_tax_total ) );
update_post_meta( $order_id, '_order_total', woocommerce_format_total( $woocommerce->cart->total ) );
update_post_meta( $order_id, '_order_shipping', woocommerce_format_decimal( $woocommerce->cart->shipping_total ) );
update_post_meta( $order_id, '_order_discount', woocommerce_format_decimal( $woocommerce->cart->get_order_discount_total() ) );
update_post_meta( $order_id, '_cart_discount', woocommerce_format_decimal( $woocommerce->cart->get_cart_discount_total() ) );
update_post_meta( $order_id, '_order_tax', woocommerce_format_decimal( $woocommerce->cart->tax_total, false ) );
update_post_meta( $order_id, '_order_shipping_tax', woocommerce_format_decimal( $woocommerce->cart->shipping_tax_total, false ) );
update_post_meta( $order_id, '_order_total', woocommerce_format_decimal( $woocommerce->cart->total ) );
update_post_meta( $order_id, '_order_key', apply_filters('woocommerce_generate_order_key', uniqid('order_') ) );
update_post_meta( $order_id, '_customer_user', absint( $this->customer_id ) );
update_post_meta( $order_id, '_order_currency', get_woocommerce_currency() );
@ -467,6 +468,9 @@ class WC_Checkout {
case "multiselect" :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? implode( ', ', array_map( 'woocommerce_clean', $_POST[ $key ] ) ) : '';
break;
case "textarea" :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? wp_strip_all_tags( wp_check_invalid_utf8( stripslashes( $_POST[ $key ] ) ) ) : '';
break;
default :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? woocommerce_clean( $_POST[ $key ] ) : '';
break;
@ -625,10 +629,10 @@ class WC_Checkout {
WC()->session->set( 'reload_checkout', true );
// Add customer info from other billing fields
if ( $this->posted['billing_first_name'] )
if ( $this->posted['billing_first_name'] && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) )
wp_update_user( array ( 'ID' => $this->customer_id, 'first_name' => $this->posted['billing_first_name'], 'display_name' => $this->posted['billing_first_name'] ) );
if ( $this->posted['billing_last_name'] )
if ( $this->posted['billing_last_name'] && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) )
wp_update_user( array ( 'ID' => $this->customer_id, 'last_name' => $this->posted['billing_last_name'] ) ) ;
}

View File

@ -51,6 +51,9 @@ class WC_Coupon {
/** @public int Coupon usage limit. */
public $usage_limit;
/** @public int Coupon usage limit per user. */
public $usage_limit_per_user;
/** @public int Coupon usage count. */
public $usage_count;
@ -104,22 +107,23 @@ class WC_Coupon {
if ( $coupon_data ) {
$this->id = absint( $coupon_data['id'] );
$this->type = esc_html( $coupon_data['type'] );
$this->amount = esc_html( $coupon_data['amount'] );
$this->individual_use = esc_html( $coupon_data['individual_use'] );
$this->product_ids = is_array( $coupon_data['product_ids'] ) ? $coupon_data['product_ids'] : array();
$this->exclude_product_ids = is_array( $coupon_data['exclude_product_ids'] ) ? $coupon_data['exclude_product_ids'] : array();
$this->usage_limit = absint( $coupon_data['usage_limit'] );
$this->usage_count = absint( $coupon_data['usage_count'] );
$this->expiry_date = esc_html( $coupon_data['expiry_date'] );
$this->apply_before_tax = esc_html( $coupon_data['apply_before_tax'] );
$this->free_shipping = esc_html( $coupon_data['free_shipping'] );
$this->product_categories = is_array( $coupon_data['product_categories'] ) ? $coupon_data['product_categories'] : array();
$this->exclude_product_categories = is_array( $coupon_data['exclude_product_categories'] ) ? $coupon_data['exclude_product_categories'] : array();
$this->exclude_sale_items = esc_html( $coupon_data['exclude_sale_items'] );
$this->minimum_amount = esc_html( $coupon_data['minimum_amount'] );
$this->customer_email = esc_html( $coupon_data['customer_email'] );
$this->id = absint( $coupon_data['id'] );
$this->type = esc_html( $coupon_data['type'] );
$this->amount = esc_html( $coupon_data['amount'] );
$this->individual_use = esc_html( $coupon_data['individual_use'] );
$this->product_ids = is_array( $coupon_data['product_ids'] ) ? $coupon_data['product_ids'] : array();
$this->exclude_product_ids = is_array( $coupon_data['exclude_product_ids'] ) ? $coupon_data['exclude_product_ids'] : array();
$this->usage_limit = absint( $coupon_data['usage_limit'] );
$this->usage_limit_per_user = absint( $coupon_data['usage_limit_per_user'] );
$this->usage_count = absint( $coupon_data['usage_count'] );
$this->expiry_date = esc_html( $coupon_data['expiry_date'] );
$this->apply_before_tax = esc_html( $coupon_data['apply_before_tax'] );
$this->free_shipping = esc_html( $coupon_data['free_shipping'] );
$this->product_categories = is_array( $coupon_data['product_categories'] ) ? $coupon_data['product_categories'] : array();
$this->exclude_product_categories = is_array( $coupon_data['exclude_product_categories'] ) ? $coupon_data['exclude_product_categories'] : array();
$this->exclude_sale_items = esc_html( $coupon_data['exclude_sale_items'] );
$this->minimum_amount = esc_html( $coupon_data['minimum_amount'] );
$this->customer_email = esc_html( $coupon_data['customer_email'] );
} else {
@ -138,21 +142,22 @@ class WC_Coupon {
$this->coupon_custom_fields = get_post_meta( $this->id );
$load_data = array(
'discount_type' => 'fixed_cart',
'coupon_amount' => 0,
'individual_use' => 'no',
'product_ids' => '',
'exclude_product_ids' => '',
'usage_limit' => '',
'usage_count' => '',
'expiry_date' => '',
'apply_before_tax' => 'yes',
'free_shipping' => 'no',
'product_categories' => array(),
'exclude_product_categories' => array(),
'exclude_sale_items' => 'no',
'minimum_amount' => '',
'customer_email' => array()
'discount_type' => 'fixed_cart',
'coupon_amount' => 0,
'individual_use' => 'no',
'product_ids' => '',
'exclude_product_ids' => '',
'usage_limit' => '',
'usage_limit_per_user' => '',
'usage_count' => '',
'expiry_date' => '',
'apply_before_tax' => 'yes',
'free_shipping' => 'no',
'product_categories' => array(),
'exclude_product_categories' => array(),
'exclude_sale_items' => 'no',
'minimum_amount' => '',
'customer_email' => array()
);
foreach ( $load_data as $key => $default )
@ -213,11 +218,15 @@ class WC_Coupon {
* Increase usage count fo current coupon.
*
* @access public
* @param string $used_by Either user ID or billing email
* @return void
*/
public function inc_usage_count() {
public function inc_usage_count( $used_by = '' ) {
$this->usage_count++;
update_post_meta( $this->id, 'usage_count', $this->usage_count );
if ( $used_by )
add_post_meta( $this->id, '_used_by', strtolower( $used_by ) );
}
@ -225,11 +234,19 @@ class WC_Coupon {
* Decrease usage count fo current coupon.
*
* @access public
* @param string $used_by Either user ID or billing email
* @return void
*/
public function dcr_usage_count() {
public function dcr_usage_count( $used_by = '' ) {
global $wpdb;
$this->usage_count--;
update_post_meta( $this->id, 'usage_count', $this->usage_count );
// Delete 1 used by meta
$meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_used_by' AND meta_value = %s AND post_id = %d LIMIT 1;", $used_by, $this->id ) );
if ( $meta_id )
delete_metadata_by_mid( 'post', $meta_id );
}
/**
@ -267,6 +284,18 @@ class WC_Coupon {
}
}
// Per user usage limit - check here if user is logged in (aginst user IDs)
// Checked again for emails later on in WC_Cart::check_customer_coupons()
if ( $this->usage_limit_per_user > 0 && is_user_logged_in() ) {
$used_by = get_post_meta( $this->id, '_used_by' );
$usage_count = sizeof( array_keys( $used_by, get_current_user_id() ) );
if ( $usage_count >= $this->usage_limit_per_user ) {
$valid = false;
$error_code = self::E_WC_COUPON_USAGE_LIMIT_REACHED;
}
}
// Expired
if ( $this->expiry_date ) {
if ( current_time( 'timestamp' ) > $this->expiry_date ) {

View File

@ -131,11 +131,12 @@ class WC_Frontend_Scripts {
) ) );
wp_localize_script( 'wc-add-to-cart', 'wc_add_to_cart_params', apply_filters( 'wc_add_to_cart_params', array(
'ajax_url' => WC()->ajax_url(),
'ajax_loader_url' => apply_filters( 'woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
'i18n_view_cart' => esc_attr__( 'View Cart &rarr;', 'woocommerce' ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
'ajax_url' => WC()->ajax_url(),
'ajax_loader_url' => apply_filters( 'woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
'i18n_view_cart' => esc_attr__( 'View Cart &rarr;', 'woocommerce' ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'is_cart' => is_cart(),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
) ) );
wp_localize_script( 'wc-add-to-cart-variation', 'wc_add_to_cart_variation_params', apply_filters( 'wc_add_to_cart_variation_params', array(

View File

@ -342,6 +342,26 @@ class WC_Order {
return $this->get_items( 'shipping' );
}
/**
* Check whether this order has a specific shipping method or not
*
* @return void
*/
public function has_shipping_method( $method_id ) {
$shipping_methods = $this->get_shipping_methods();
$has_method = false;
if ( !$shipping_methods )
return false;
foreach ( $shipping_methods as $shipping_method ) {
if ( $shipping_method['method_id'] == $method_id )
$has_method = true;
}
return $has_method;
}
/**
* Get taxes, merged by code, formatted ready for output.
*
@ -1364,7 +1384,12 @@ class WC_Order {
continue;
$coupon = new WC_Coupon( $code );
$coupon->inc_usage_count();
$used_by = $this->user_id;
if ( ! $used_by )
$used_by = $this->billing_email;
$coupon->inc_usage_count( $used_by );
}
}
@ -1390,7 +1415,12 @@ class WC_Order {
continue;
$coupon = new WC_Coupon( $code );
$coupon->dcr_usage_count();
$used_by = $this->user_id;
if ( ! $used_by )
$used_by = $this->billing_email;
$coupon->dcr_usage_count( $used_by );
}
}

View File

@ -547,9 +547,9 @@ class WC_Query {
/**
* Appends meta queries to an array.
*
* @access public
* @return void
* @param array $meta_query
* @return array
*/
public function get_meta_query( $meta_query = array() ) {
if ( ! is_array( $meta_query ) )
@ -757,7 +757,7 @@ class WC_Query {
* @param array $filtered_posts
* @return array
*/
public function price_filter($filtered_posts) {
public function price_filter( $filtered_posts ) {
global $wpdb;
if ( isset( $_GET['max_price'] ) && isset( $_GET['min_price'] ) ) {
@ -766,11 +766,11 @@ class WC_Query {
$min = floatval( $_GET['min_price'] );
$max = floatval( $_GET['max_price'] );
$matched_products_query = $wpdb->get_results( $wpdb->prepare("
$matched_products_query = apply_filters( 'woocommerce_price_filter_results', $wpdb->get_results( $wpdb->prepare("
SELECT DISTINCT ID, post_parent, post_type FROM $wpdb->posts
INNER JOIN $wpdb->postmeta ON ID = post_id
WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish' AND meta_key = %s AND meta_value BETWEEN %d AND %d
", '_price', $min, $max ), OBJECT_K );
", '_price', $min, $max ), OBJECT_K ), $min, $max );
if ( $matched_products_query ) {
foreach ( $matched_products_query as $product ) {

View File

@ -114,11 +114,12 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
),
'cost_per_order' => array(
'title' => __( 'Cost per order', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'Enter a cost (excluding tax) per order, e.g. 5.00. Leave blank to disable.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
'placeholder' => '0.00',
),
'options' => array(
'title' => __( 'Additional Rates', 'woocommerce' ),
@ -148,7 +149,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
),
'minimum_fee' => array(
'title' => __( 'Minimum Handling Fee', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
@ -534,8 +536,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
<tr>
<td></td>
<td class="flat_rate_class"><?php _e( 'Any class', 'woocommerce' ); ?></td>
<td><input type="text" value="<?php echo esc_attr( $this->cost ); ?>" name="default_cost" placeholder="<?php _e( 'N/A', 'woocommerce' ); ?>" size="4" class="wc_input_price" /></td>
<td><input type="text" value="<?php echo esc_attr( $this->fee ); ?>" name="default_fee" placeholder="<?php _e( 'N/A', 'woocommerce' ); ?>" size="4" /></td>
<td><input type="text" value="<?php echo esc_attr( $this->cost ); ?>" name="default_cost" placeholder="<?php _e( 'N/A', 'woocommerce' ); ?>" size="4" class="wc_input_decimal" /></td>
<td><input type="text" value="<?php echo esc_attr( $this->fee ); ?>" name="default_fee" placeholder="<?php _e( 'N/A', 'woocommerce' ); ?>" size="4" class="wc_input_decimal" /></td>
</tr>
<?php
$i = -1;
@ -558,8 +560,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
echo '</select>
</td>
<td><input type="number" step="any" min="0" value="' . esc_attr( $rate['cost'] ) . '" name="' . esc_attr( $this->id .'_cost[' . $i . ']' ) . '" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" /></td>
<td><input type="text" value="' . esc_attr( $rate['fee'] ) . '" name="' . esc_attr( $this->id .'_fee[' . $i . ']' ) . '" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" /></td>
<td><input type="text" value="' . esc_attr( $rate['cost'] ) . '" name="' . esc_attr( $this->id .'_cost[' . $i . ']' ) . '" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" class="wc_input_decimal" /></td>
<td><input type="text" value="' . esc_attr( $rate['fee'] ) . '" name="' . esc_attr( $this->id .'_fee[' . $i . ']' ) . '" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" class="wc_input_decimal" /></td>
</tr>';
}
}
@ -588,8 +590,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
?>\
</select>\
</td>\
<td><input type="number" step="any" min="0" name="<?php echo $this->id; ?>_cost[' + size + ']" placeholder="0.00" size="4" /></td>\
<td><input type="text" name="<?php echo $this->id; ?>_fee[' + size + ']" placeholder="0.00" size="4" /></td>\
<td><input type="text" name="<?php echo $this->id; ?>_cost[' + size + ']" placeholder="0.00" size="4" class="wc_input_decimal" /></td>\
<td><input type="text" name="<?php echo $this->id; ?>_fee[' + size + ']" placeholder="0.00" size="4" class="wc_input_decimal" /></td>\
</tr>').appendTo('#<?php echo $this->id; ?>_flat_rates table tbody');
return false;
@ -628,8 +630,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
$flat_rates = array();
if ( isset( $_POST[ $this->id . '_class'] ) ) $flat_rate_class = array_map( 'woocommerce_clean', $_POST[ $this->id . '_class'] );
if ( isset( $_POST[ $this->id . '_cost'] ) ) $flat_rate_cost = array_map( 'woocommerce_clean', $_POST[ $this->id . '_cost'] );
if ( isset( $_POST[ $this->id . '_fee'] ) ) $flat_rate_fee = array_map( 'woocommerce_clean', $_POST[ $this->id . '_fee'] );
if ( isset( $_POST[ $this->id . '_cost'] ) ) $flat_rate_cost = array_map( 'stripslashes', $_POST[ $this->id . '_cost'] );
if ( isset( $_POST[ $this->id . '_fee'] ) ) $flat_rate_fee = array_map( 'stripslashes', $_POST[ $this->id . '_fee'] );
// Get max key
$values = $flat_rate_class;
@ -640,7 +642,12 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
for ( $i = 0; $i <= $key; $i++ ) {
if ( ! empty( $flat_rate_class[ $i ] ) && isset( $flat_rate_cost[ $i ] ) && isset( $flat_rate_fee[ $i ] ) ) {
$flat_rate_cost[$i] = number_format($flat_rate_cost[$i], 2, '.', '');
$flat_rate_cost[ $i ] = woocommerce_format_decimal( $flat_rate_cost[$i], 2 );
if ( ! strstr( $flat_rate_fee[$i], '%' ) )
$flat_rate_fee[ $i ] = woocommerce_format_decimal( $flat_rate_fee[$i], 2 );
else
$flat_rate_fee[ $i ] = woocommerce_clean( $flat_rate_fee[$i] );
// Add to flat rates array
$flat_rates[ sanitize_title($flat_rate_class[$i]) ] = array(
@ -663,8 +670,12 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
* @return void
*/
function save_default_costs( $fields ) {
$default_cost = woocommerce_clean( $_POST['default_cost'] );
$default_fee = woocommerce_clean( $_POST['default_fee'] );
$default_cost = ( $_POST['default_cost'] === '' ) ? '' : woocommerce_format_decimal( $_POST['default_cost'], false );
if ( ! strstr( $_POST['default_fee'], '%' ) )
$default_fee = ( $_POST['default_fee'] === '' ) ? '' : woocommerce_format_decimal( $_POST['default_fee'], false );
else
$default_fee = woocommerce_clean( $_POST['default_fee'] );
$fields['cost'] = $default_cost;
$fields['fee'] = $default_fee;

View File

@ -116,7 +116,8 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
),
'min_amount' => array(
'title' => __( 'Minimum Order Amount', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'Users will need to spend this amount to get free shipping (if enabled above).', 'woocommerce' ),
'default' => '0',
'desc_tip' => true,

View File

@ -98,7 +98,8 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
),
'cost' => array(
'title' => __( 'Cost', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
@ -114,7 +115,8 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
),
'minimum_fee' => array(
'title' => __( 'Minimum Handling Fee', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,

View File

@ -121,7 +121,8 @@ class WC_Shipping_Local_Delivery extends WC_Shipping_Method {
),
'fee' => array(
'title' => __( 'Delivery Fee', 'woocommerce' ),
'type' => 'price',
'type' => 'text',
'class' => 'wc_input_decimal',
'description' => __( 'What fee do you want to charge for local delivery, disregarded if you choose free. Leave blank to disable.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,

View File

@ -22,12 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
* @return void
*/
function woocommerce_sanitize_taxonomy_name( $taxonomy ) {
$taxonomy = strtolower( stripslashes( strip_tags( $taxonomy ) ) );
$taxonomy = preg_replace( '/&.+?;/', '', $taxonomy ); // Kill entities
$taxonomy = str_replace( array( '.', '\'', '"' ), '', $taxonomy ); // Kill quotes and full stops.
$taxonomy = str_replace( array( ' ', '_' ), '-', $taxonomy ); // Replace spaces and underscores.
$filtered = strtolower( remove_accents( stripslashes( strip_tags( $taxonomy ) ) ) );
$filtered = preg_replace( '/&.+?;/', '', $filtered ); // Kill entities
$filtered = str_replace( array( '.', '\'', '"' ), '', $filtered ); // Kill quotes and full stops.
$filtered = str_replace( array( ' ', '_' ), '-', $filtered ); // Replace spaces and underscores.
return $taxonomy;
return apply_filters( 'sanitize_taxonomy_name', $filtered, $taxonomy );
}
/**
@ -156,19 +156,37 @@ function woocommerce_trim_zeros( $price ) {
}
/**
* Formal decimal numbers - format to 4 dp and remove trailing zeros.
* Format decimal numbers - format to a defined number of dp and remove trailing zeros.
*
* @access public
* @param mixed $number
* Remove's user locale settings, converting to a string which uses '.' for decimals, with no thousand separators.
*
* @param float|string $number
* @param mixed $dp number of decimal points to use, blank to use woocommerce_price_num_decimals, or false to avoid all rounding.
* @param boolean $trim_zeros from end of string
* @return string
*/
function woocommerce_format_decimal( $number, $dp = '' ) {
if ( $dp == '' )
$dp = intval( get_option( 'woocommerce_price_num_decimals' ) );
function woocommerce_format_decimal( $number, $dp = '', $trim_zeros = false ) {
$number = floatval( $number );
$number = number_format( (float) $number, (int) $dp, '.', '' );
// DP is false - don't use number format, just remove locale settings from the number
if ( $dp === false ) {
$locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
if ( strstr( $number, '.' ) )
// Only allow numbers and the decimal point
if ( strstr( $number, $decimal ) )
$number = preg_replace( "/[^0-9\\" . $decimal . "]/", "", strval( $number ) );
else
$number = preg_replace( "/[^0-9.]/", "", strval( $number ) );
// Replace decimal point with .
$number = str_replace( $decimal, '.', $number );
} else {
$dp = ( $dp == "" ) ? intval( get_option( 'woocommerce_price_num_decimals' ) ) : intval( $dp );
$number = number_format( $number, $dp, '.', '' );
}
if ( $trim_zeros && strstr( $number, '.' ) )
$number = rtrim( rtrim( $number, '0' ), '.' );
return $number;
@ -179,10 +197,10 @@ function woocommerce_format_decimal( $number, $dp = '' ) {
*
* @access public
* @param mixed $number
* @return float
* @return string
*/
function woocommerce_format_total( $number ) {
return number_format( (float) $number, (int) get_option( 'woocommerce_price_num_decimals' ), '.', '' );
return woocommerce_format_decimal( $number, '', false );
}
/**

View File

@ -160,14 +160,7 @@ function woocommerce_get_product_ids_on_sale() {
GROUP BY post.ID;
" );
$product_ids_on_sale = array();
foreach ( $on_sale_posts as $post ) {
$product_ids_on_sale[] = $post->ID;
$product_ids_on_sale[] = $post->post_parent;
}
$product_ids_on_sale = array_unique( $product_ids_on_sale );
$product_ids_on_sale = array_unique( array_merge( wp_list_pluck( $on_sale_posts, 'ID' ), wp_list_pluck( $on_sale_posts, 'post_parent' ) ) );
set_transient( 'wc_products_onsale', $product_ids_on_sale );

View File

@ -186,7 +186,7 @@ add_action( 'wp_head', 'wc_generator_tag' );
* @see wc_print_js()
*/
add_action( 'wp_footer', 'woocommerce_demo_store' );
add_action( 'wp_footer', 'wc_print_js' );
add_action( 'wp_footer', 'wc_print_js', 25 );
/**
* Order details

View File

@ -185,6 +185,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Feature - woocommerce_get_featured_product_ids function.
* Feature - WOOCOMMERCE_DELIMITER to customise the pipes for attributes
* Feature - Standardized, default credit card form for gateways to use if they support 'default_credit_card_form'.
* Feature - Coupon usage limits per user (using email + ID).
* Tweak - Added pagination to tax rate screens.
* Tweak - Added filter to check the 'Create account' checkbox on checkout by default.
* Tweak - Update CPT parameters for 'product_variation' and 'shop_coupon' to be no longer public.

View File

@ -64,7 +64,7 @@ do_action( 'woocommerce_before_cart' ); ?>
if ( ! $_product->is_visible() )
echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key );
else
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', ( $cart_item['variation'] ? add_query_arg( $cart_item['variation'], $_product->get_permalink() ) : $_product->get_permalink() ), $_product->get_title() ), $cart_item, $cart_item_key );
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', ( is_array( $cart_item['variation'] ) ? add_query_arg( $cart_item['variation'], $_product->get_permalink() ) : $_product->get_permalink() ), $_product->get_title() ), $cart_item, $cart_item_key );
// Meta data
echo $woocommerce->cart->get_item_data( $cart_item );

View File

@ -910,9 +910,9 @@ function woocommerce_ajax_add_order_item() {
$item['name'] = $_product->get_title();
$item['tax_class'] = $_product->get_tax_class();
$item['qty'] = 1;
$item['line_subtotal'] = number_format( (double) $_product->get_price_excluding_tax(), 2, '.', '' );
$item['line_subtotal'] = woocommerce_format_decimal( $_product->get_price_excluding_tax(), false );
$item['line_subtotal_tax'] = '';
$item['line_total'] = number_format( (double) $_product->get_price_excluding_tax(), 2, '.', '' );
$item['line_total'] = woocommerce_format_decimal( $_product->get_price_excluding_tax(), false );
$item['line_tax'] = '';
// Add line item