Skip to content

Commit 878ab6e

Browse files
author
Leonix
committed
Shop-Script v.9.0.5
* Eliminated unnecessary displaying of fractional product quantities if they are disabled in the settings. * Eliminated export of fractional product quantities to CSV files if they are disabled in the settings. * Restored the option to save negative product stock quantities. * Restored the availability of purchasing more product items than are available in stock if this option is enabled in the settings. * Restore the option to save zero product quantities when editing orders. * Fixed displaying of negative product quantities in the store backend. * For the users of the PREMIUM license: * Fixed saving of selected product quantity units when editing orders. * Fixed product filtering by their base quantity units’ prices. * Fixed execution of the order refund action for items with fractional quantities.
1 parent 127695c commit 878ab6e

File tree

51 files changed

+292
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+292
-138
lines changed

css/backend/orders/refund.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/backend/orders/refund.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ var OrderRefundSection = ( function($) {
104104
}
105105
});
106106

107+
that.$products.on("keyup click", ".js-quantity-field", function() {
108+
var $invalid_quantity = $(this).parents('.s-product-wrapper').find('.s-product-invalid-quantity');
109+
110+
if ($(this).is(':invalid')) {
111+
$invalid_quantity.show();
112+
} else {
113+
$invalid_quantity.hide();
114+
}
115+
});
116+
107117
that.$products.on("change", ".js-quantity-field", function(event, force) {
108118
var $field = $(this),
109119
$product = $field.closest(".s-product-wrapper"),
@@ -134,8 +144,6 @@ var OrderRefundSection = ( function($) {
134144
if (value < 0 ) { value = 0; }
135145
if (max > 0 && value > max) { value = max; }
136146

137-
value = Math.ceil(value);
138-
139147
return value;
140148
}
141149
});
@@ -156,6 +164,7 @@ var OrderRefundSection = ( function($) {
156164
var max = ( is_active ? ( parseFloat($quantity.attr("max")) || 1 ) : 0 );
157165
$quantity.val(max).trigger("change", true);
158166
}
167+
$quantity.click();
159168

160169
var $checkboxes = that.$products.find(".js-product-checkbox:not(.is-disabled)"),
161170
count = $checkboxes.length,

js/backend/products/product/product.general.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,7 @@
28762876

28772877
$.each(sku_mod.stock, function(stock_id, stock_value) {
28782878
var value = parseFloat(stock_value);
2879-
if (value >= 0) {
2879+
if (Math.abs(value) >= 0) {
28802880
is_stocks_mode = true;
28812881
} else {
28822882
value = "";

js/backend/products/product/product.sku.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,8 +3427,6 @@
34273427
target_value = $field.val(),
34283428
value = (typeof target_value === "string" ? target_value : "" + target_value);
34293429

3430-
value = $.wa.validate(type, value);
3431-
34323430
switch (type) {
34333431
case "price":
34343432
value = $.wa.validate("number", value);
@@ -3450,23 +3448,14 @@
34503448
}
34513449
}
34523450

3453-
break;
3454-
case "number":
3455-
value = $.wa.validate("number", value);
3456-
break;
3457-
case "integer":
3458-
value = $.wa.validate("integer", value);
34593451
break;
34603452
default:
3453+
value = $.wa.validate(type, value);
34613454
break;
34623455
}
34633456

34643457
// set
3465-
set(value);
3466-
3467-
function set(value) {
3468-
Vue.set(data, key, value);
3469-
}
3458+
self.$set(data, key, value);
34703459
},
34713460

34723461
//
@@ -4838,9 +4827,7 @@
48384827
is_stocks_mode = true;
48394828

48404829
var value = parseFloat(stock_value);
4841-
if (value < 0) {
4842-
value = "";
4843-
}
4830+
if (isNaN(value)) { value = ""; }
48444831

48454832
stocks_data.push({
48464833
name: prefix + "[stock][" + stock_id + "]",

js/backend/products/wa2.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,32 @@ $.wa = $.extend($.wa || {}, {
35513551
result = letters_array.join("");
35523552
break;
35533553

3554+
case "number-negative":
3555+
var white_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", ",", "-"],
3556+
letters_array = [],
3557+
divider_exist = false;
3558+
3559+
$.each(value.split(""), function(i, letter) {
3560+
if (letter === "-") {
3561+
if (letters_array.length === 0) {
3562+
letters_array.push(letter);
3563+
}
3564+
} else if (letter === "." || letter === ",") {
3565+
letter = ".";
3566+
if (!divider_exist) {
3567+
divider_exist = true;
3568+
letters_array.push(letter);
3569+
}
3570+
} else {
3571+
if (white_list.indexOf(letter) >= 0) {
3572+
letters_array.push(letter);
3573+
}
3574+
}
3575+
});
3576+
3577+
result = letters_array.join("");
3578+
break;
3579+
35543580
case "integer":
35553581
var white_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
35563582
letters_array = [];

js/backend/settings/compatibility/compatibility.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
$loading = $("<i class=\"icon16 loading\" />");
7272

7373
var plugin_id = $field.closest(".s-item-row").data("plugin-id"),
74-
app_id = $field.closest(".s-item-row").data("app-id"),
74+
app_id = $field.closest(".s-item-row").data("app-id") || $field.closest(".s-app-row").data("app-id"),
7575
is_checked = $(this).is(":checked");
7676

7777
var data = {
@@ -98,11 +98,7 @@
9898
function request(data) {
9999
var deferred = $.Deferred();
100100

101-
// setTimeout( function() {
102-
// deferred.resolve();
103-
// }, 2000);
104-
105-
$.post(that.urls["plugin_status"], data, "json")
101+
$.post(that.urls["asset_status"], data, "json")
106102
.fail( function() {
107103
deferred.reject();
108104
})

js/order/edit.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ $.order_edit = {
874874

875875
if (parseFloat(value) > 0) {
876876
//
877-
} else {
877+
} else if (parseFloat(value) !== 0) {
878878
that.$field.val(that.min);
879879
value = that.min;
880880
}
@@ -952,23 +952,25 @@ $.order_edit = {
952952
value = (typeof value !== "number" ? parseFloat(value) : value);
953953
value = parseFloat(value.toFixed(3));
954954

955+
var min = 0.001;
956+
955957
if (value > 0) {
956958
// левая граница
957-
if (value < that.min) { value = that.min; }
959+
if (value < min) { value = min; }
958960
// правая граница
959-
else if (that.max && (that.max > that.min) && (value > that.max)) {
961+
else if (that.max && (that.max > min) && (value > that.max)) {
960962
value = that.max;
961963
}
962964
// центр
963-
else {
964-
var steps_count = Math.floor(value/that.denominator);
965-
var x1 = (that.denominator * steps_count).toFixed(3) * 1;
966-
if (x1 !== value) {
967-
value = that.denominator * (steps_count + 1);
968-
}
969-
}
970-
} else {
971-
value = that.min;
965+
// else {
966+
// var steps_count = Math.floor(value/that.denominator);
967+
// var x1 = (that.denominator * steps_count).toFixed(3) * 1;
968+
// if (x1 !== value) {
969+
// value = that.denominator * (steps_count + 1);
970+
// }
971+
// }
972+
} else if (value !== 0) {
973+
value = min;
972974
}
973975

974976
return validate("float", value);

0 commit comments

Comments
 (0)