diff --git a/app/assets/javascripts/alchemy/solidus/admin/variant_select.js b/app/assets/javascripts/alchemy/solidus/admin/variant_select.js
index 160452a..c9f573b 100644
--- a/app/assets/javascripts/alchemy/solidus/admin/variant_select.js
+++ b/app/assets/javascripts/alchemy/solidus/admin/variant_select.js
@@ -1,7 +1,25 @@
//= require alchemy/solidus/admin/select2_config
$.fn.alchemyVariantSelect = function(options) {
- var config = Alchemy.Solidus.getSelect2Config(options)
+ const config = Alchemy.Solidus.getSelect2Config(options)
+
+ function formatSelection(variant) {
+ return variant.options_text ? `${variant.name} - ${variant.options_text}` : variant.name
+ }
+
+ function formatResult(variant) {
+ return `
+
+
+ ${variant.name}
+
+
+ ${variant.options_text}
+ ${variant.sku}
+
+
+ `
+ }
this.select2($.extend(true, config, {
ajax: {
@@ -15,18 +33,12 @@ $.fn.alchemyVariantSelect = function(options) {
},
results: function(data, page) {
return {
- results: data.variants.map(function(variant) {
- return {
- id: variant.id,
- text: variant.frontend_display
- }
- }),
+ results: data.variants,
more: page * data.per_page < data.total_count
}
}
},
- formatSelection: function(variant) {
- return variant.text || variant.frontend_display
- }
+ formatSelection,
+ formatResult
}))
}
diff --git a/app/views/alchemy/ingredients/_spree_variant_editor.html.erb b/app/views/alchemy/ingredients/_spree_variant_editor.html.erb
index 5a4ebf4..8d50d67 100644
--- a/app/views/alchemy/ingredients/_spree_variant_editor.html.erb
+++ b/app/views/alchemy/ingredients/_spree_variant_editor.html.erb
@@ -10,6 +10,25 @@
<% end %>
<% end %>
+
+