spree_backend 3.6.6 → 3.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +7 -7
- data/app/assets/javascripts/spree/backend/address_states.js +21 -21
- data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
- data/app/assets/javascripts/spree/backend/admin.js +253 -244
- data/app/assets/javascripts/spree/backend/calculator.js +14 -13
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +48 -52
- data/app/assets/javascripts/spree/backend/gateway.js +11 -10
- data/app/assets/javascripts/spree/backend/general_settings.js +18 -0
- data/app/assets/javascripts/spree/backend/handlebar_extensions.js +6 -6
- data/app/assets/javascripts/spree/backend/line_items.js +72 -0
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +48 -47
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +10 -10
- data/app/assets/javascripts/spree/backend/option_value_picker.js +13 -14
- data/app/assets/javascripts/spree/backend/orders/edit.js +3 -4
- data/app/assets/javascripts/spree/backend/payments/edit.js +230 -0
- data/app/assets/javascripts/spree/backend/payments/new.js +31 -31
- data/app/assets/javascripts/spree/backend/product_picker.js +15 -15
- data/app/assets/javascripts/spree/backend/progress.js +8 -0
- data/app/assets/javascripts/spree/backend/promotions.js +102 -107
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +5 -0
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +32 -33
- data/app/assets/javascripts/spree/backend/shipments.js +246 -241
- data/app/assets/javascripts/spree/backend/spree-select2.js +3 -3
- data/app/assets/javascripts/spree/backend/states.js +8 -8
- data/app/assets/javascripts/spree/backend/stock_location.js +4 -3
- data/app/assets/javascripts/spree/backend/stock_management.js +13 -0
- data/app/assets/javascripts/spree/backend/stock_movement.js +35 -0
- data/app/assets/javascripts/spree/backend/stock_transfer.js +260 -0
- data/app/assets/javascripts/spree/backend/tag_picker.js +21 -21
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +13 -13
- data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +8 -9
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +35 -0
- data/app/assets/javascripts/spree/backend/taxonomy.js +165 -0
- data/app/assets/javascripts/spree/backend/taxons.js +122 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +11 -11
- data/app/assets/javascripts/spree/backend/users/edit.js +14 -15
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +61 -0
- data/app/assets/javascripts/spree/backend/variant_management.js +14 -0
- data/app/assets/javascripts/spree/backend/zone.js +44 -0
- data/app/controllers/spree/admin/countries_controller.rb +3 -3
- data/app/controllers/spree/admin/customer_returns_controller.rb +1 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
- data/app/controllers/spree/admin/orders_controller.rb +4 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -0
- data/app/controllers/spree/admin/payments_controller.rb +3 -2
- data/app/controllers/spree/admin/products_controller.rb +3 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -0
- data/app/controllers/spree/admin/properties_controller.rb +1 -0
- data/app/controllers/spree/admin/reports_controller.rb +4 -4
- data/app/controllers/spree/admin/resource_controller.rb +3 -1
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/return_index_controller.rb +1 -0
- data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +1 -2
- data/app/controllers/spree/admin/users_controller.rb +3 -1
- data/app/helpers/spree/admin/base_helper.rb +8 -5
- data/app/helpers/spree/admin/{general_settings_helper.rb → currency_helper.rb} +4 -3
- data/app/helpers/spree/admin/navigation_helper.rb +0 -8
- data/app/helpers/spree/admin/orders_helper.rb +2 -1
- data/app/models/spree/admin/resource.rb +1 -0
- data/app/views/spree/admin/orders/_line_items.html.erb +3 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +15 -8
- data/app/views/spree/admin/products/index.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/properties/index.html.erb +2 -2
- data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -1
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
- data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
- data/app/views/spree/admin/store_credits/_form.html.erb +15 -6
- data/app/views/spree/admin/store_credits/edit.html.erb +1 -1
- data/app/views/spree/admin/store_credits/new.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +8 -8
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/lib/generators/spree/backend/copy_views/copy_views_generator.rb +1 -1
- data/lib/spree/backend/callbacks.rb +1 -0
- data/spree_backend.gemspec +2 -2
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +4358 -4358
- data/vendor/assets/javascripts/js.cookie.js +165 -0
- metadata +28 -28
- data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
- data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -15
- data/app/assets/javascripts/spree/backend/line_items.js.coffee +0 -64
- data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -145
- data/app/assets/javascripts/spree/backend/progress.js.coffee +0 -6
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +0 -4
- data/app/assets/javascripts/spree/backend/stock_management.js.coffee +0 -9
- data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +0 -19
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -201
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js.coffee +0 -22
- data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -153
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -82
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -38
- data/app/assets/javascripts/spree/backend/variant_management.js.coffee +0 -10
- data/app/assets/javascripts/spree/backend/zone.js.coffee +0 -43
- data/vendor/assets/javascripts/jquery.cookie.js +0 -117
@@ -1,16 +1,17 @@
|
|
1
|
-
$(function() {
|
2
|
-
var
|
3
|
-
var
|
4
|
-
$('.calculator-settings-warning').hide()
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
$('.calculator-settings
|
9
|
-
$('.calculator-settings').
|
1
|
+
$(function () {
|
2
|
+
var calculatorSelect = $('select#calc_type')
|
3
|
+
var originalCalcType = calculatorSelect.prop('value')
|
4
|
+
$('.calculator-settings-warning').hide()
|
5
|
+
calculatorSelect.change(function () {
|
6
|
+
// eslint-disable-next-line eqeqeq
|
7
|
+
if (calculatorSelect.prop('value') == originalCalcType) {
|
8
|
+
$('div.calculator-settings').show()
|
9
|
+
$('.calculator-settings-warning').hide()
|
10
|
+
$('.calculator-settings').find('input,textarea').prop('disabled', false)
|
10
11
|
} else {
|
11
|
-
$('div.calculator-settings').hide()
|
12
|
-
$('.calculator-settings-warning').show()
|
13
|
-
$('.calculator-settings').find('input,texttarea').prop(
|
12
|
+
$('div.calculator-settings').hide()
|
13
|
+
$('.calculator-settings-warning').show()
|
14
|
+
$('.calculator-settings').find('input,texttarea').prop('disabled', true)
|
14
15
|
}
|
15
|
-
})
|
16
|
+
})
|
16
17
|
})
|
@@ -1,20 +1,20 @@
|
|
1
1
|
//= require_self
|
2
|
+
/* global customerTemplate, update_state */
|
3
|
+
// eslint-disable-next-line camelcase
|
4
|
+
var clear_address_fields = function () {
|
5
|
+
var fields = ['firstname', 'lastname', 'company', 'address1', 'address2', 'city', 'zipcode', 'state_id', 'country_id', 'phone']
|
6
|
+
$.each(fields, function (i, field) {
|
7
|
+
$('#order_bill_address_attributes_' + field).val('')
|
8
|
+
$('#order_ship_address_attributes_' + field).val('')
|
9
|
+
})
|
10
|
+
}
|
2
11
|
|
3
|
-
|
4
|
-
var fields = ['firstname', 'lastname', 'company', 'address1', 'address2',
|
5
|
-
'city', 'zipcode', 'state_id', 'country_id', 'phone'];
|
6
|
-
$.each(fields, function(i, field) {
|
7
|
-
$('#order_bill_address_attributes_' + field).val('');
|
8
|
-
$('#order_ship_address_attributes_' + field).val('');
|
9
|
-
});
|
10
|
-
};
|
11
|
-
|
12
|
-
$(document).ready(function() {
|
12
|
+
$(document).ready(function () {
|
13
13
|
if ($('#customer_autocomplete_template').length > 0) {
|
14
|
-
window.customerTemplate = Handlebars.compile($('#customer_autocomplete_template').text())
|
14
|
+
window.customerTemplate = Handlebars.compile($('#customer_autocomplete_template').text())
|
15
15
|
}
|
16
16
|
|
17
|
-
formatCustomerResult = function(customer) {
|
17
|
+
var formatCustomerResult = function (customer) {
|
18
18
|
return customerTemplate({
|
19
19
|
customer: customer,
|
20
20
|
bill_address: customer.bill_address,
|
@@ -29,7 +29,7 @@ $(document).ready(function() {
|
|
29
29
|
url: Spree.routes.users_api,
|
30
30
|
datatype: 'json',
|
31
31
|
cache: true,
|
32
|
-
data: function(term, page) {
|
32
|
+
data: function (term, page) {
|
33
33
|
return {
|
34
34
|
q: {
|
35
35
|
'm': 'or',
|
@@ -42,62 +42,58 @@ $(document).ready(function() {
|
|
42
42
|
token: Spree.api_key
|
43
43
|
}
|
44
44
|
},
|
45
|
-
results: function(data, page) {
|
45
|
+
results: function (data, page) {
|
46
46
|
return { results: data.users }
|
47
47
|
}
|
48
48
|
},
|
49
49
|
dropdownCssClass: 'customer_search',
|
50
50
|
formatResult: formatCustomerResult,
|
51
51
|
formatSelection: function (customer) {
|
52
|
-
$('#order_email').val(customer.email)
|
53
|
-
$('#order_user_id').val(customer.id)
|
54
|
-
$('#guest_checkout_true').prop('checked', false)
|
55
|
-
$('#guest_checkout_false').prop('checked', true)
|
56
|
-
$('#guest_checkout_false').prop('disabled', false)
|
52
|
+
$('#order_email').val(customer.email)
|
53
|
+
$('#order_user_id').val(customer.id)
|
54
|
+
$('#guest_checkout_true').prop('checked', false)
|
55
|
+
$('#guest_checkout_false').prop('checked', true)
|
56
|
+
$('#guest_checkout_false').prop('disabled', false)
|
57
57
|
|
58
|
-
var billAddress = customer.bill_address
|
59
|
-
if(billAddress) {
|
60
|
-
$('#order_bill_address_attributes_firstname').val(billAddress.firstname)
|
61
|
-
$('#order_bill_address_attributes_lastname').val(billAddress.lastname)
|
62
|
-
$('#order_bill_address_attributes_address1').val(billAddress.address1)
|
63
|
-
$('#order_bill_address_attributes_address2').val(billAddress.address2)
|
64
|
-
$('#order_bill_address_attributes_city').val(billAddress.city)
|
65
|
-
$('#order_bill_address_attributes_zipcode').val(billAddress.zipcode)
|
66
|
-
$('#order_bill_address_attributes_phone').val(billAddress.phone)
|
58
|
+
var billAddress = customer.bill_address
|
59
|
+
if (billAddress) {
|
60
|
+
$('#order_bill_address_attributes_firstname').val(billAddress.firstname)
|
61
|
+
$('#order_bill_address_attributes_lastname').val(billAddress.lastname)
|
62
|
+
$('#order_bill_address_attributes_address1').val(billAddress.address1)
|
63
|
+
$('#order_bill_address_attributes_address2').val(billAddress.address2)
|
64
|
+
$('#order_bill_address_attributes_city').val(billAddress.city)
|
65
|
+
$('#order_bill_address_attributes_zipcode').val(billAddress.zipcode)
|
66
|
+
$('#order_bill_address_attributes_phone').val(billAddress.phone)
|
67
67
|
|
68
68
|
$('#order_bill_address_attributes_country_id').select2('val', billAddress.country_id).promise().done(function () {
|
69
69
|
update_state('b', function () {
|
70
|
-
$('#order_bill_address_attributes_state_id').select2('val', billAddress.state_id)
|
71
|
-
})
|
72
|
-
})
|
70
|
+
$('#order_bill_address_attributes_state_id').select2('val', billAddress.state_id)
|
71
|
+
})
|
72
|
+
})
|
73
73
|
} else {
|
74
|
-
clear_address_fields()
|
74
|
+
clear_address_fields()
|
75
75
|
}
|
76
|
-
return Select2.util.escapeMarkup(customer.email)
|
76
|
+
return Select2.util.escapeMarkup(customer.email)
|
77
77
|
}
|
78
78
|
})
|
79
79
|
}
|
80
80
|
|
81
|
-
var
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
$('#shipping').show();
|
81
|
+
var orderUseBillingInput = $('input#order_use_billing')
|
82
|
+
var orderUseBilling = function () {
|
83
|
+
if (!orderUseBillingInput.is(':checked')) {
|
84
|
+
$('#shipping').show()
|
86
85
|
} else {
|
87
|
-
$('#shipping').hide()
|
86
|
+
$('#shipping').hide()
|
88
87
|
}
|
89
|
-
}
|
90
|
-
|
91
|
-
order_use_billing_input.click(function() {
|
92
|
-
order_use_billing();
|
93
|
-
});
|
88
|
+
}
|
94
89
|
|
95
|
-
|
90
|
+
orderUseBillingInput.click(orderUseBilling)
|
91
|
+
orderUseBilling()
|
96
92
|
|
97
|
-
$('#guest_checkout_true').change(function() {
|
98
|
-
$('#customer_search').val('')
|
99
|
-
$('#order_user_id').val('')
|
100
|
-
$('#order_email').val('')
|
101
|
-
clear_address_fields()
|
102
|
-
})
|
103
|
-
})
|
93
|
+
$('#guest_checkout_true').change(function () {
|
94
|
+
$('#customer_search').val('')
|
95
|
+
$('#order_user_id').val('')
|
96
|
+
$('#order_email').val('')
|
97
|
+
clear_address_fields()
|
98
|
+
})
|
99
|
+
})
|
@@ -1,13 +1,14 @@
|
|
1
|
-
$(function() {
|
2
|
-
var
|
3
|
-
$('div#gateway-settings-warning').hide()
|
4
|
-
$('#gtwy-type').change(function() {
|
5
|
-
|
6
|
-
|
7
|
-
$('div
|
1
|
+
$(function () {
|
2
|
+
var originalGtwyType = $('#gtwy-type').prop('value')
|
3
|
+
$('div#gateway-settings-warning').hide()
|
4
|
+
$('#gtwy-type').change(function () {
|
5
|
+
// eslint-disable-next-line eqeqeq
|
6
|
+
if ($('#gtwy-type').prop('value') == originalGtwyType) {
|
7
|
+
$('div.gateway-settings').show()
|
8
|
+
$('div#gateway-settings-warning').hide()
|
8
9
|
} else {
|
9
|
-
$('div.gateway-settings').hide()
|
10
|
-
$('div#gateway-settings-warning').show()
|
10
|
+
$('div.gateway-settings').hide()
|
11
|
+
$('div#gateway-settings-warning').show()
|
11
12
|
}
|
12
|
-
})
|
13
|
+
})
|
13
14
|
})
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/* global show_flash */
|
2
|
+
$(function () {
|
3
|
+
$('[data-hook=general_settings_clear_cache] #clear_cache').click(function () {
|
4
|
+
if (confirm(Spree.translations.are_you_sure)) {
|
5
|
+
$.post(Spree.routes.clear_cache)
|
6
|
+
.done(function () {
|
7
|
+
show_flash('success', 'Cache was flushed.')
|
8
|
+
})
|
9
|
+
.fail(function (message) {
|
10
|
+
if (message.responseJSON['error']) {
|
11
|
+
show_flash('error', message.responseJSON['error'])
|
12
|
+
} else {
|
13
|
+
show_flash('error', 'There was a problem while flushing cache.')
|
14
|
+
}
|
15
|
+
})
|
16
|
+
}
|
17
|
+
})
|
18
|
+
})
|
@@ -1,10 +1,10 @@
|
|
1
|
-
Handlebars.registerHelper(
|
1
|
+
Handlebars.registerHelper('t', function (key) {
|
2
2
|
if (Spree.translations[key]) {
|
3
3
|
return Spree.translations[key]
|
4
4
|
} else {
|
5
|
-
console.error(
|
5
|
+
console.error('No translation found for ' + key + '. Does it exist within spree/admin/shared/_translations.html.erb?')
|
6
6
|
}
|
7
|
-
})
|
8
|
-
Handlebars.registerHelper(
|
9
|
-
return Spree.routes.edit_product(
|
10
|
-
})
|
7
|
+
})
|
8
|
+
Handlebars.registerHelper('edit_product_url', function (productId) {
|
9
|
+
return Spree.routes.edit_product(productId)
|
10
|
+
})
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* global toggleItemEdit, order_number */
|
2
|
+
$(function () {
|
3
|
+
// handle edit click
|
4
|
+
$('a.edit-line-item').click(toggleLineItemEdit)
|
5
|
+
// handle cancel click
|
6
|
+
$('a.cancel-line-item').click(toggleLineItemEdit)
|
7
|
+
// handle save click
|
8
|
+
$('a.save-line-item').click(function () {
|
9
|
+
var save = $(this)
|
10
|
+
var lineItemId = save.data('line-item-id')
|
11
|
+
var quantity = parseInt(save.parents('tr').find('input.line_item_quantity').val())
|
12
|
+
toggleItemEdit()
|
13
|
+
adjustLineItem(lineItemId, quantity)
|
14
|
+
})
|
15
|
+
// handle delete click
|
16
|
+
$('a.delete-line-item').click(function () {
|
17
|
+
if (confirm(Spree.translations.are_you_sure_delete)) {
|
18
|
+
var del = $(this)
|
19
|
+
var lineItemId = del.data('line-item-id')
|
20
|
+
toggleItemEdit()
|
21
|
+
deleteLineItem(lineItemId)
|
22
|
+
}
|
23
|
+
})
|
24
|
+
})
|
25
|
+
|
26
|
+
function toggleLineItemEdit () {
|
27
|
+
var link = $(this)
|
28
|
+
var parent = link.parent()
|
29
|
+
var tr = link.parents('tr')
|
30
|
+
parent.find('a.edit-line-item').toggle()
|
31
|
+
parent.find('a.cancel-line-item').toggle()
|
32
|
+
parent.find('a.save-line-item').toggle()
|
33
|
+
parent.find('a.delete-line-item').toggle()
|
34
|
+
tr.find('td.line-item-qty-show').toggle()
|
35
|
+
tr.find('td.line-item-qty-edit').toggle()
|
36
|
+
}
|
37
|
+
|
38
|
+
function lineItemURL (lineItemId) {
|
39
|
+
// eslint-disable-next-line camelcase
|
40
|
+
return Spree.routes.orders_api + '/' + order_number + '/line_items/' + lineItemId + '.json'
|
41
|
+
}
|
42
|
+
|
43
|
+
function adjustLineItem (lineItemId, quantity) {
|
44
|
+
$.ajax({
|
45
|
+
type: 'PUT',
|
46
|
+
url: Spree.url(lineItemURL(lineItemId)),
|
47
|
+
data: {
|
48
|
+
line_item: {
|
49
|
+
quantity: quantity
|
50
|
+
},
|
51
|
+
token: Spree.api_key
|
52
|
+
}
|
53
|
+
}).done(function () {
|
54
|
+
window.Spree.advanceOrder()
|
55
|
+
})
|
56
|
+
}
|
57
|
+
|
58
|
+
function deleteLineItem (lineItemId) {
|
59
|
+
$.ajax({
|
60
|
+
type: 'DELETE',
|
61
|
+
url: Spree.url(lineItemURL(lineItemId)),
|
62
|
+
headers: {
|
63
|
+
'X-Spree-Token': Spree.api_key
|
64
|
+
}
|
65
|
+
}).done(function () {
|
66
|
+
$('#line-item-' + lineItemId).remove()
|
67
|
+
if ($('.line-items tr.line-item').length === 0) {
|
68
|
+
$('.line-items').remove()
|
69
|
+
}
|
70
|
+
window.Spree.advanceOrder()
|
71
|
+
})
|
72
|
+
}
|
@@ -1,52 +1,53 @@
|
|
1
|
+
/* global variantLineItemTemplate, order_number */
|
1
2
|
// This file contains the code for interacting with line items in the manual cart
|
2
3
|
$(document).ready(function () {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
})
|
18
|
-
|
19
|
-
addVariant
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
return 1
|
4
|
+
'use strict'
|
5
|
+
|
6
|
+
// handle variant selection, show stock level.
|
7
|
+
$('#add_line_item_variant_id').change(function () {
|
8
|
+
var variantId = $(this).val()
|
9
|
+
|
10
|
+
var variant = _.find(window.variants, function (variant) {
|
11
|
+
// eslint-disable-next-line eqeqeq
|
12
|
+
return variant.id == variantId
|
13
|
+
})
|
14
|
+
$('#stock_details').html(variantLineItemTemplate({ variant: variant }))
|
15
|
+
$('#stock_details').show()
|
16
|
+
$('button.add_variant').click(addVariant)
|
17
|
+
})
|
18
|
+
})
|
19
|
+
|
20
|
+
function addVariant () {
|
21
|
+
$('#stock_details').hide()
|
22
|
+
var variantId = $('input.variant_autocomplete').val()
|
23
|
+
var quantity = $("input.quantity[data-variant-id='" + variantId + "']").val()
|
24
|
+
|
25
|
+
adjustLineItems(order_number, variantId, quantity)
|
26
|
+
return 1
|
27
27
|
}
|
28
28
|
|
29
|
-
adjustLineItems
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
29
|
+
function adjustLineItems (orderNumber, variantId, quantity) {
|
30
|
+
var url = Spree.routes.orders_api + '/' + orderNumber + '/line_items'
|
31
|
+
|
32
|
+
$.ajax({
|
33
|
+
type: 'POST',
|
34
|
+
url: Spree.url(url),
|
35
|
+
data: {
|
36
|
+
line_item: {
|
37
|
+
variant_id: variantId,
|
38
|
+
quantity: quantity
|
39
|
+
},
|
40
|
+
token: Spree.api_key
|
41
|
+
}
|
42
|
+
}).done(function (msg) {
|
43
|
+
window.Spree.advanceOrder()
|
44
|
+
window.location.reload()
|
45
|
+
}).fail(function (msg) {
|
46
|
+
// eslint-disable-next-line eqeqeq
|
47
|
+
if (typeof msg.responseJSON.message != 'undefined') {
|
48
|
+
alert(msg.responseJSON.message)
|
49
|
+
} else {
|
50
|
+
alert(msg.responseJSON.exception)
|
51
|
+
}
|
52
|
+
})
|
52
53
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
$(document).ready(function () {
|
2
|
-
'use strict'
|
2
|
+
'use strict'
|
3
3
|
|
4
|
-
function formatOptionType(
|
5
|
-
return Select2.util.escapeMarkup(
|
4
|
+
function formatOptionType (optionType) {
|
5
|
+
return Select2.util.escapeMarkup(optionType.presentation + ' (' + optionType.name + ')')
|
6
6
|
}
|
7
7
|
|
8
8
|
if ($('#product_option_type_ids').length > 0) {
|
@@ -13,10 +13,10 @@ $(document).ready(function () {
|
|
13
13
|
var url = Spree.url(Spree.routes.option_types_api, {
|
14
14
|
ids: element.val(),
|
15
15
|
token: Spree.api_key
|
16
|
-
})
|
16
|
+
})
|
17
17
|
return $.getJSON(url, null, function (data) {
|
18
|
-
return callback(data)
|
19
|
-
})
|
18
|
+
return callback(data)
|
19
|
+
})
|
20
20
|
},
|
21
21
|
ajax: {
|
22
22
|
url: Spree.routes.option_types_api,
|
@@ -28,16 +28,16 @@ $(document).ready(function () {
|
|
28
28
|
name_cont: term
|
29
29
|
},
|
30
30
|
token: Spree.api_key
|
31
|
-
}
|
31
|
+
}
|
32
32
|
},
|
33
33
|
results: function (data) {
|
34
34
|
return {
|
35
35
|
results: data
|
36
|
-
}
|
36
|
+
}
|
37
37
|
}
|
38
38
|
},
|
39
39
|
formatResult: formatOptionType,
|
40
40
|
formatSelection: formatOptionType
|
41
|
-
})
|
41
|
+
})
|
42
42
|
}
|
43
|
-
})
|
43
|
+
})
|