caboose-cms 0.9.31 → 0.9.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edd4495325ae1e2e44f453bbd23603ab339b7345
4
- data.tar.gz: 3a36acac988b41eb9aaabf5121f46c69c27f0284
3
+ metadata.gz: e7e918dcb7efd1eb157ba0b54dc180d342e962e8
4
+ data.tar.gz: 2cda5ba3ae8b731a65f16a439c1093bd8c419c97
5
5
  SHA512:
6
- metadata.gz: 0f5b923f8d7b8b1bf9b938ee8425f6ef37e4f171383ffe4c5b32e5410b7a380b8ac640bdaa001718c893d016bab7dc77162da151643f979fbd94cb8ffb8498bc
7
- data.tar.gz: aec65c0bbb515e9a0894122b75fdd1d3894f591ff36b8349aa249b1bcce992869f91f46152013794eb3d97227b40785bed61c4aa7d83994c92b307c48508d9c2
6
+ metadata.gz: 5022f3cd6e8dad98eba1ea3a07732c13bde07f21fb0a055b2cdbee482451811dc596d5b672884a3dc61a91dd5ea03ae967d28bc0d6da8d0694ca0f30e048e326
7
+ data.tar.gz: 1b62d17eee2a6bb6f3d5de84496c75afa657914ddd5ef1c66f2eded7aeb1e18ae0806c01e332869729dd237efb3159d05415cf0dbe2e43f2f5030aa628f51230
@@ -99,7 +99,7 @@ Caboose.Store.Modules.Cart = (function() {
99
99
  type: $form.attr('method'),
100
100
  url: $form.attr('action'),
101
101
  data: $form.serialize(),
102
- success: function(response) {
102
+ success: function(response) {
103
103
  if (response.success) {
104
104
  self.render_item_count(response.item_count);
105
105
  if (self.$add_to_cart.length) self.$add_to_cart.trigger('added');
@@ -123,9 +123,9 @@ Caboose.Store.Modules.Cart = (function() {
123
123
  } else {
124
124
  if (!self.$add_to_cart.find('.message').length) {
125
125
  self.$add_to_cart
126
- .append($('<div/>').hide().addClass('note error')
127
- .append($('<p/>').text(response.error ? response.error : (response.errors ? response.errors[0] : "Error adding to cart")))
128
- .append($('<p/>').append($('<a/>').attr('href', '/cart').html('View cart')))
126
+ .append($('<div/>').hide().addClass('message')
127
+ .append($('<p/>').addClass('note error').html(response.error ? response.error : (response.errors ? response.errors[0] : "Error adding to cart")))
128
+ // .append($('<p/>').append($('<a/>').attr('href', '/cart').html('View cart')))
129
129
  );
130
130
  self.$add_to_cart.find('.message').fadeIn();
131
131
  }
@@ -232,35 +232,50 @@ CheckoutController.prototype = {
232
232
  Invoice confirmation
233
233
  *****************************************************************************/
234
234
 
235
- confirm_invoice: function(t)
235
+ confirm_invoice: function(total_is_ok, variant_limits_are_ok)
236
236
  {
237
237
  var that = this;
238
238
 
239
- $('#message').html("<p class='loading'>Verifying order total...</p>");
240
- var t = $.ajax_value('/checkout/total');
241
- if (parseFloat(t) != that.invoice.total)
239
+ if (!total_is_ok)
242
240
  {
243
- $('#message').html("<p class='note error'>It looks like the order total has changed since this was loaded. Please submit your order again after this page refreshes.</p>");
244
- setTimeout(function() { window.location.reload(true); }, 3000);
241
+ $('#message').html("<p class='loading'>Verifying order total...</p>");
242
+ $.get('/checkout/total', function(x) {
243
+ if (parseFloat(x) != that.invoice.total)
244
+ {
245
+ $('#message').html("<p class='note error'>It looks like the order total has changed since this was loaded. Please submit your order again after this page refreshes.</p>");
246
+ setTimeout(function() { window.location.reload(true); }, 3000);
247
+ }
248
+ else
249
+ that.confirm_invoice(true);
250
+ });
251
+ return;
252
+ }
253
+ if (!variant_limits_are_ok)
254
+ {
255
+ $('#message').html("<p class='loading'>Verifying limits...</p>");
256
+ $.get('/cart/check-variant-limits', function(resp) {
257
+ if (resp.success) that.confirm_invoice(true, true);
258
+ if (resp.error)
259
+ {
260
+ $('#message').html("<p class='note error'>" + resp.error + "</p>");
261
+ setTimeout(function() { window.location.reload(true); }, 3000);
262
+ }
263
+ });
245
264
  return;
246
265
  }
247
266
 
248
267
  $('#message').html("<p class='loading'>Processing payment...</p>");
249
- $.ajax({
250
- url: '/checkout/confirm',
251
- type: 'post',
252
- success: function(resp) {
253
- if (resp.success) window.location = '/checkout/thanks';
254
- if (resp.error)
255
- {
256
- $('#message').empty()
257
- .append($('<p/>').addClass('note error').append(resp.error))
258
- .append($('<p/>')
259
- .append($('<input/>').attr('type', 'button').val('Make Changes' ).click(function(e) { that.print(); })).append(' ')
260
- .append($('<input/>').attr('type', 'button').val('Confirm Order').click(function(e) { that.confirm_invoice(); }))
261
- );
262
- }
263
- }
268
+ $.post('/checkout/confirm', function(resp) {
269
+ if (resp.success) window.location = '/checkout/thanks';
270
+ if (resp.error)
271
+ {
272
+ $('#message').empty()
273
+ .append($('<p/>').addClass('note error').append(resp.error))
274
+ .append($('<p/>')
275
+ .append($('<input/>').attr('type', 'button').val('Make Changes' ).click(function(e) { that.print(); })).append(' ')
276
+ .append($('<input/>').attr('type', 'button').val('Confirm Order').click(function(e) { that.confirm_invoice(); }))
277
+ );
278
+ }
264
279
  });
265
280
  },
266
281
 
@@ -37,6 +37,66 @@ module Caboose
37
37
  render :json => { :item_count => @invoice.item_count }
38
38
  end
39
39
 
40
+ # @route GET /cart/check-variant-limits
41
+ def check_variant_limits
42
+ resp = StdClass.new
43
+ errors = []
44
+
45
+ if @invoice.nil?
46
+ errors << "No invoice found."
47
+ else
48
+ @invoice.line_items.each do |li|
49
+ vl = VariantLimit.where(:variant_id => li.variant_id, :user_id => @logged_in_user.id).first
50
+ vl = VariantLimit.where(:variant_id => li.variant_id, :user_id => User.logged_out_user_id(@site.id)).first if vl.nil?
51
+ next if vl.nil?
52
+
53
+ if vl.no_purchases_allowed(@invoice)
54
+
55
+ InvoiceLog.create(:invoice_id => @invoice.id, :line_item_id => li.id, :user_id => logged_in_user.id, :date_logged => DateTime.now.utc, :invoice_action => InvoiceLog::ACTION_LINE_ITEM_DELETED)
56
+ if li.invoice_package_id
57
+ li.invoice_package.shipping_method_id = nil
58
+ li.invoice_package.total = nil
59
+ li.invoice_package.save
60
+ end
61
+ li.destroy
62
+ @invoice.shipping = 0.00
63
+
64
+ errors << "You don't have permission to purchase this item." + (!logged_in? ? "You may have different purchase permissions if you <a href='/login'>login</a>." : '')
65
+ next
66
+
67
+ end
68
+
69
+ qty = vl.current_value ? vl.current_value + li.quantity : li.quantity
70
+ next if vl.qty_within_range(qty, @invoice)
71
+
72
+ error = vl.quantity_message(@invoice)
73
+ if !logged_in?
74
+ error << "You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
75
+ if vl.qty_too_low(li.quantity, @invoice) then li.quantity = vl.min_quantity(@invoice)
76
+ elsif vl.qty_too_high(qty, @invoice) then li.quantity = vl.max_quantity(@invoice)
77
+ end
78
+ else
79
+ if vl.qty_too_low(li.quantity, @invoice)
80
+ li.quantity = vl.min_quantity(@invoice)
81
+ error = "You must purchase at least #{li.quantity} of this item, your cart has been updated."
82
+ elsif vl.qty_too_high(qty, @invoice)
83
+ li.quantity = vl.max_quantity(@invoice) - vl.current_value
84
+ error = "You can only purchase #{li.quantity} of this item, your cart has been updated."
85
+ end
86
+ end
87
+ li.save
88
+ errors << error
89
+ end
90
+ if errors.count > 0
91
+ @invoice.calculate
92
+ resp.error = errors.join("<br/>")
93
+ else
94
+ resp.success = true
95
+ end
96
+ end
97
+ render :json => resp
98
+ end
99
+
40
100
  # @route POST /cart
41
101
  def add
42
102
  resp = StdClass.new
@@ -51,27 +111,34 @@ module Caboose
51
111
  # Check the variant limits
52
112
  vl = VariantLimit.where(:variant_id => v.id, :user_id => @logged_in_user.id).first
53
113
  vl = VariantLimit.where(:variant_id => v.id, :user_id => User.logged_out_user_id(@site.id)).first if vl.nil?
54
- if vl && vl.no_purchases_allowed
114
+ if vl && vl.no_purchases_allowed(@invoice)
55
115
  resp.error = "You don't have permission to purchase this item."
56
- resp.error << "You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
116
+ resp.error << " You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
57
117
  render :json => resp
58
118
  return
59
119
  end
60
120
  qty2 = logged_in? && vl && vl.current_value ? qty + vl.current_value : qty
61
- if vl && !vl.qty_within_range(qty2)
62
- resp.quantity_message = vl.quantity_message
63
- if !logged_in?
121
+ if vl && !vl.qty_within_range(qty2, @invoice)
122
+ resp.quantity_message = vl.quantity_message(@invoice)
123
+ if !logged_in?
64
124
  resp.quantity_message << "You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
65
- if vl.qty_too_low(qty) then qty = vl.min_quantity
66
- elsif vl.qty_too_high(qty) then qty = vl.max_quantity
125
+ if vl.qty_too_low(qty, @invoice) then qty = vl.min_quantity(@invoice)
126
+ elsif vl.qty_too_high(qty, @invoice) then qty = vl.max_quantity(@invoice)
67
127
  end
68
- else
69
- if vl.qty_too_low(qty)
70
- qty = vl.min_quantity
71
- resp.quantity_message = "You must purchase at least #{vl.min_quantity} of this item, your cart has been updated."
72
- elsif vl.qty_too_high(qty2)
73
- qty = vl.max_quantity - vl.current_value
74
- resp.quantity_message = "You can only purchase #{vl.max_quantity} of this item, your cart has been updated."
128
+ else
129
+ if vl.qty_too_low(qty, @invoice)
130
+ qty = vl.min_quantity(@invoice)
131
+ resp.quantity_message = "You must purchase at least #{vl.min_quantity(@invoice)} of this item, your cart has been updated."
132
+ elsif vl.qty_too_high(qty2, @invoice)
133
+ qty = vl.max_quantity(@invoice) - vl.current_value
134
+ if vl.max_quantity == vl.current_value
135
+ resp.success = false
136
+ resp.error = "You have already purchased the maximum quantity allowed for this item."
137
+ render :json => resp
138
+ return
139
+ else
140
+ resp.quantity_message = "You can only purchase #{qty} of this item, your cart has been updated."
141
+ end
75
142
  end
76
143
  end
77
144
  end
@@ -145,23 +212,23 @@ module Caboose
145
212
  # Check the variant limits
146
213
  vl = VariantLimit.where(:variant_id => li.variant_id, :user_id => @logged_in_user.id).first
147
214
  vl = VariantLimit.where(:variant_id => li.variant_id, :user_id => User.logged_out_user_id(@site.id)).first if vl.nil?
148
- if vl && vl.no_purchases_allowed
215
+ if vl && vl.no_purchases_allowed(@invoice)
149
216
  resp.error = "You don't have permission to purchase this item."
150
217
  resp.error << "You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
151
218
  render :json => resp
152
219
  return
153
220
  end
154
221
  qty2 = logged_in? && vl && vl.current_value ? qty + vl.current_value : qty
155
- if vl && !vl.qty_within_range(qty2)
156
- resp.quantity_message = vl.quantity_message
222
+ if vl && !vl.qty_within_range(qty2, @invoice)
223
+ resp.quantity_message = vl.quantity_message(@invoice)
157
224
  if !logged_in?
158
225
  resp.quantity_message << "You may have different purchase permissions if you <a href='/login'>login</a>." if !logged_in?
159
- if vl.qty_too_low(qty) then qty = vl.min_quantity
160
- elsif vl.qty_too_high(qty) then qty = vl.max_quantity
226
+ if vl.qty_too_low(qty, @invoice) then qty = vl.min_quantity(@invoice)
227
+ elsif vl.qty_too_high(qty, @invoice) then qty = vl.max_quantity(@invoice)
161
228
  end
162
229
  else
163
- if vl.qty_too_low(qty) then qty = (qty == 0 ? 0 : vl.min_quantity)
164
- elsif vl.qty_too_high(qty2) then qty = vl.max_quantity - vl.current_value
230
+ if vl.qty_too_low(qty, @invoice) then qty = (qty == 0 ? 0 : vl.min_quantity(@invoice))
231
+ elsif vl.qty_too_high(qty2, @invoice) then qty = vl.max_quantity(@invoice) - vl.current_value
165
232
  end
166
233
  end
167
234
  end
@@ -207,6 +207,8 @@ module Caboose
207
207
 
208
208
  resp = Caboose::StdClass.new
209
209
  sc = @site.store_config
210
+
211
+ @invoice.customer.create_variant_limits if @invoice.customer
210
212
 
211
213
  # Make sure all the variants still exist
212
214
  @invoice.line_items.each do |li|
@@ -215,7 +217,7 @@ module Caboose
215
217
  if v.nil? || v.status == 'Deleted'
216
218
  render :json => { :error => 'One or more of the products you are purchasing are no longer available.' }
217
219
  return
218
- elsif vl && !vl.qty_within_range( vl.current_value + li.quantity )
220
+ elsif vl && !vl.qty_within_range(vl.current_value + li.quantity, @invoice)
219
221
  render :json => { :error => 'You have exceeded the limit you are allowed to purchase.' }
220
222
  return
221
223
  end
@@ -313,14 +315,14 @@ module Caboose
313
315
  add_ga_event('Ecommerce', 'Checkout', 'Payment', (@last_invoice.total*100).to_i)
314
316
  end
315
317
 
316
- #===========================================================================
318
+ #===========================================================================
317
319
 
318
320
  # @route GET /checkout/state-options
319
321
  def state_options
320
322
  options = Caboose::States.all.collect { |abbr, state| { 'value' => abbr, 'text' => abbr }}
321
323
  render :json => options
322
324
  end
323
-
325
+
324
326
  # @route GET /checkout/total
325
327
  def verify_total
326
328
  total = 0.00
@@ -71,7 +71,7 @@ module Caboose
71
71
 
72
72
  elsif params[:id].to_i > 0 && Product.exists?(params[:id])
73
73
  @product = Product.find(params[:id])
74
- render 'product/not_available' and return if @product.status == 'Inactive' || @product.site_id != @site.id
74
+ render 'caboose/products/not_available' and return if @product.status == 'Inactive' || @product.site_id != @site.id
75
75
 
76
76
  @category = @product.categories.first
77
77
  @review = Review.new
@@ -31,7 +31,7 @@ module Caboose
31
31
  render :json => variantlimit.as_json(:include => [:variant])
32
32
  end
33
33
 
34
- # @route POST /admin/variant-limits
34
+ # @route POST /admin/users/:user_id/variant-limits
35
35
  def admin_add
36
36
  return unless (user_is_allowed_to 'edit', 'variantlimits')
37
37
  resp = Caboose::StdClass.new
@@ -39,16 +39,30 @@ module Caboose
39
39
  resp.error = 'That variant is already added to this user.'
40
40
  else
41
41
  c = VariantLimit.new
42
- c.user_id = params[:user_id]
43
- c.variant_id = params[:variant_id]
42
+ c.user_id = params[:user_id]
43
+ c.variant_id = params[:variant_id]
44
44
  c.min_quantity_value = 0
45
45
  c.max_quantity_value = 0
46
- c.current_value = 0
46
+ c.current_value = 0
47
47
  c.save
48
48
  resp.success = true
49
49
  end
50
50
  render :json => resp
51
51
  end
52
+
53
+ # @route PUT /admin/variant-limits/new/:variant_id
54
+ def admin_create
55
+ resp = Caboose::StdClass.new
56
+ mq = params[:max_quantity_value]
57
+ elo = User.where(:site_id => @site.id, :username => 'elo').first
58
+ vl = VariantLimit.where(:user_id => elo.id, :variant_id => params[:variant_id]).first
59
+ vl = VariantLimit.create(:user_id => elo.id, :variant_id => params[:variant_id]) if vl.nil?
60
+ vl.max_quantity_value = mq.blank? ? nil : mq
61
+ vl.min_quantity_value = 0
62
+ vl.current_value = 0
63
+ resp.success = vl.save
64
+ render :json => resp
65
+ end
52
66
 
53
67
  # @route PUT /admin/variant-limits/:id
54
68
  # @route PUT /admin/users/:user_id/variant-limits/:id
@@ -58,7 +72,6 @@ module Caboose
58
72
  variantlimit = VariantLimit.find(params[:id])
59
73
  user = logged_in_user
60
74
  if user
61
-
62
75
  params.each do |k,v|
63
76
  case k
64
77
  when "user_id" then variantlimit.user_id = v
@@ -70,7 +83,6 @@ module Caboose
70
83
  when "current_value" then variantlimit.current_value = v
71
84
  end
72
85
  end
73
-
74
86
  resp.success = variantlimit.save
75
87
  end
76
88
  render :json => resp
@@ -89,6 +101,18 @@ module Caboose
89
101
  @variant_limit = Caboose::VariantLimit.find(params[:id])
90
102
  end
91
103
 
104
+ # @route DELETE /admin/variant-limits/bulk
105
+ def admin_bulk_delete
106
+ return if !user_is_allowed('variantlimits', 'delete')
107
+ resp = Caboose::StdClass.new
108
+ params[:model_ids].each do |vl_id|
109
+ vl = VariantLimit.find(vl_id)
110
+ vl.destroy
111
+ end
112
+ resp.success = true
113
+ render :json => resp
114
+ end
115
+
92
116
  # @route_priority 1
93
117
  # @route GET /admin/variant-limits/variant-options
94
118
  def admin_variant_options
@@ -83,6 +83,25 @@ class Caboose::User < ActiveRecord::Base
83
83
  end
84
84
  return true
85
85
  end
86
+
87
+ def create_variant_limits
88
+ elo = Caboose::User.where(:site_id => self.site_id, :username => 'elo').first if !self.site_id.blank?
89
+ variant_limits = Caboose::VariantLimit.where(:user_id => elo.id).all if elo
90
+ if variant_limits && variant_limits.count > 0
91
+ variant_limits.each do |vl|
92
+ new_vl = Caboose::VariantLimit.where(:user_id => self.id, :variant_id => vl.variant_id).first
93
+ if new_vl.nil?
94
+ new_vl = Caboose::VariantLimit.create(:user_id => self.id, :variant_id => vl.variant_id)
95
+ new_vl.min_quantity_value = vl.min_quantity_value
96
+ new_vl.min_quantity_func = vl.min_quantity_func
97
+ new_vl.max_quantity_value = vl.max_quantity_value
98
+ new_vl.max_quantity_func = vl.max_quantity_func
99
+ new_vl.current_value = 0
100
+ new_vl.save
101
+ end
102
+ end
103
+ end
104
+ end
86
105
 
87
106
  def is_member?(role_id)
88
107
  roles.each do |r|
@@ -13,49 +13,49 @@ module Caboose
13
13
  :max_quantity_func ,
14
14
  :current_value
15
15
 
16
- def min_quantity
16
+ def min_quantity(invoice)
17
17
  return self.min_quantity_value if self.min_quantity_func.nil? || self.min_quantity_func.strip.length == 0
18
18
  return eval(self.min_quantity_func)
19
19
  end
20
20
 
21
- def max_quantity
21
+ def max_quantity(invoice)
22
22
  return self.max_quantity_value if self.max_quantity_func.nil? || self.max_quantity_func.strip.length == 0
23
23
  return eval(self.max_quantity_func)
24
24
  end
25
25
 
26
- def quantity_message
27
- if self.min_quantity == 0 && self.max_quantity == 0
26
+ def quantity_message(invoice)
27
+ if self.min_quantity(invoice) == 0 && self.max_quantity(invoice) == 0
28
28
  return "You are not allowed to purchase this item."
29
29
  end
30
- if self.max_quantity
31
- if self.min_quantity && self.min_quantity > 0
32
- return "You are allowed to purchase between #{self.min_quantity} and #{self.max_quantity} of this item."
30
+ if self.max_quantity(invoice)
31
+ if self.min_quantity(invoice) && self.min_quantity(invoice) > 0
32
+ return "You are allowed to purchase between #{self.min_quantity(invoice)} and #{self.max_quantity(invoice)} of this item."
33
33
  else
34
- return "You are allowed to purchase up to #{self.max_quantity} of this item."
34
+ return "You are allowed to purchase up to #{self.max_quantity(invoice)} of this item."
35
35
  end
36
36
  end
37
- if self.min_quantity && self.min_quantity > 0
38
- return "You must purchase at least #{self.min_quantity} of this item."
37
+ if self.min_quantity(invoice) && self.min_quantity(invoice) > 0
38
+ return "You must purchase at least #{self.min_quantity(invoice)} of this item."
39
39
  end
40
40
  return nil
41
41
  end
42
42
 
43
- def no_purchases_allowed
44
- return self.min_quantity == 0 && self.max_quantity == 0
43
+ def no_purchases_allowed(invoice)
44
+ return self.min_quantity(invoice) == 0 && self.max_quantity(invoice) == 0
45
45
  end
46
46
 
47
- def qty_within_range(qty)
48
- return false if self.min_quantity && qty < self.min_quantity
49
- return false if self.max_quantity && qty > self.max_quantity
47
+ def qty_within_range(qty, invoice)
48
+ return false if self.min_quantity(invoice) && qty < self.min_quantity(invoice)
49
+ return false if self.max_quantity(invoice) && qty > self.max_quantity(invoice)
50
50
  return true
51
51
  end
52
52
 
53
- def qty_too_low(qty)
54
- return self.min_quantity && qty < self.min_quantity
53
+ def qty_too_low(qty, invoice)
54
+ return self.min_quantity(invoice) && qty < self.min_quantity(invoice)
55
55
  end
56
56
 
57
- def qty_too_high(qty)
58
- return self.max_quantity && qty > self.max_quantity
57
+ def qty_too_high(qty, invoice)
58
+ return self.max_quantity(invoice) && qty > self.max_quantity(invoice)
59
59
  end
60
60
 
61
61
  end
@@ -6,7 +6,9 @@
6
6
  <p><div id='variantlimit_<%= @variant_limit.id %>_min_quantity_func' ></div></p>
7
7
  <p><div id='variantlimit_<%= @variant_limit.id %>_max_quantity_value' ></div></p>
8
8
  <p><div id='variantlimit_<%= @variant_limit.id %>_max_quantity_func' ></div></p>
9
- <p><div id='variantlimit_<%= @variant_limit.id %>_current_value' ></div></p>
9
+ <p>Quantity Purchased: <%= @variant_limit.current_value %></p>
10
+
11
+ <a href="/admin/users/<%= @edituser.id %>/variant-limits" class="caboose-btn">Back</a>
10
12
 
11
13
  <%= render :partial => 'caboose/users/admin_footer' %>
12
14
 
@@ -25,8 +27,7 @@ $(document).ready(function() {
25
27
  { name: 'min_quantity_value' , nice_name: 'Min Qty Value' , type: 'text' , value: <%= raw Caboose.json(@variant_limit.min_quantity_value ) %>, width: 600 },
26
28
  { name: 'min_quantity_func' , nice_name: 'Min Qty Function' , type: 'textarea' , value: <%= raw Caboose.json(@variant_limit.min_quantity_func ) %>, width: 600 , height: 100 },
27
29
  { name: 'max_quantity_value' , nice_name: 'Max Qty Value' , type: 'text' , value: <%= raw Caboose.json(@variant_limit.max_quantity_value ) %>, width: 600 },
28
- { name: 'max_quantity_func' , nice_name: 'Max Qty Function' , type: 'textarea' , value: <%= raw Caboose.json(@variant_limit.max_quantity_func ) %>, width: 600 , height: 100 },
29
- { name: 'current_value' , nice_name: 'Purchased' , type: 'text' , value: <%= raw Caboose.json(@variant_limit.current_value ) %>, width: 600 }
30
+ { name: 'max_quantity_func' , nice_name: 'Max Qty Function' , type: 'textarea' , value: <%= raw Caboose.json(@variant_limit.max_quantity_func ) %>, width: 600 , height: 100 }
30
31
  ]
31
32
  });
32
33
  });
@@ -20,17 +20,17 @@ $(document).ready(function() {
20
20
  allow_advanced_edit: true,
21
21
  allow_import: false,
22
22
  fields: [
23
- { show: true, editable: true , bulk_edit: false, name: 'variant_id' , nice_name: 'Product Variant' , sort: 'variant_id' , type: 'select' , value: function(r) { return r.variant_id }, width: 150 , text: function(r) { return (r.variant ? (r.variant.alternate_id ? r.variant.alternate_id : r.variant.id) : '') }, options_url: '/admin/variant-limits/variant-options' },
24
- { show: true, editable: true , bulk_edit: false, name: 'min_quantity_value' , nice_name: 'Min Qty Value' , sort: 'min_quantity_value' , type: 'text' , value: function(r) { return r.min_quantity_value }, width: 150 },
25
- { show: true, editable: true , bulk_edit: false, name: 'min_quantity_func' , nice_name: 'Min Qty Function' , sort: 'min_quantity_func' , type: 'textarea' , value: function(r) { return r.min_quantity_func }, width: 150 },
26
- { show: true, editable: true , bulk_edit: false, name: 'max_quantity_value' , nice_name: 'Max Qty Value' , sort: 'max_quantity_value' , type: 'text' , value: function(r) { return r.max_quantity_value }, width: 150 },
27
- { show: true, editable: true , bulk_edit: false, name: 'max_quantity_func' , nice_name: 'Max Qty Function' , sort: 'max_quantity_func' , type: 'textarea' , value: function(r) { return r.max_quantity_func }, width: 150 },
28
- { show: true, editable: false, bulk_edit: false, name: 'current_value' , nice_name: 'Purchased' , sort: 'current_value' , type: 'text' , value: function(r) { return r.current_value }, width: 150 }
23
+ { show: true , editable: true , bulk_edit: false, name: 'variant_id' , nice_name: 'Product Variant' , sort: 'variant_id' , type: 'select' , value: function(r) { return r.variant_id }, width: 150 , text: function(r) { return (r.variant ? (r.variant.alternate_id ? r.variant.alternate_id : r.variant.id) : '') }, options_url: '/admin/variant-limits/variant-options' },
24
+ { show: true , editable: true , bulk_edit: false, name: 'min_quantity_value' , nice_name: 'Min Qty' , sort: 'min_quantity_value' , type: 'text' , value: function(r) { return r.min_quantity_value }, width: 150 },
25
+ { show: false, editable: true , bulk_edit: false, name: 'min_quantity_func' , nice_name: 'Min Qty Function' , sort: 'min_quantity_func' , type: 'textarea' , value: function(r) { return r.min_quantity_func }, width: 150 },
26
+ { show: true , editable: true , bulk_edit: false, name: 'max_quantity_value' , nice_name: 'Max Qty' , sort: 'max_quantity_value' , type: 'text' , value: function(r) { return r.max_quantity_value }, width: 150 },
27
+ { show: false, editable: true , bulk_edit: false, name: 'max_quantity_func' , nice_name: 'Max Qty Function' , sort: 'max_quantity_func' , type: 'textarea' , value: function(r) { return r.max_quantity_func }, width: 150 },
28
+ { show: true , editable: false, bulk_edit: false, name: 'current_value' , nice_name: 'Purchased' , sort: 'current_value' , type: 'text' , value: function(r) { return r.current_value }, width: 150 }
29
29
  ],
30
30
  new_model_text: 'New Variant Limit',
31
31
  new_model_fields: [
32
- { name: 'variant_id', nice_name: 'Product', type: 'select', width: 400, options_url: '/admin/variant-limits/variant-options' },
33
- { name: 'user_id', nice_name: 'User', type: 'hidden', width: 400, value: <%= @edituser.id %> }
32
+ { name: 'variant_id' , nice_name: 'Product', type: 'select', width: 400, options_url: '/admin/variant-limits/variant-options' },
33
+ { name: 'user_id' , nice_name: 'User', type: 'hidden', width: 400, value: <%= @edituser.id %> }
34
34
  ]
35
35
  });
36
36
  });
@@ -22,7 +22,9 @@ v = @variant
22
22
  <div id='variant_<%= v.id %>_cost' ></div>
23
23
  <div id='variant_<%= v.id %>_price' ></div>
24
24
  <div id='variant_<%= v.id %>_quantity_in_stock' ></div>
25
- <div id='variant_<%= v.id %>_ignore_quantity' ></div>
25
+ <div id='variant_<%= v.id %>_ignore_quantity' ></div>
26
+ <div id='variant_<%= v.id %>_max_quantity_value' ></div>
27
+ <div id='variant_<%= v.id %>_min_quantity_value' ></div>
26
28
 
27
29
  <h2>Dimensions</h2>
28
30
  <div id='variant_<%= v.id %>_cylinder' ></div>
@@ -84,6 +86,8 @@ v = @variant
84
86
  <script type='text/javascript'>
85
87
  <%
86
88
  sc = @site.store_config
89
+ elo = Caboose::User.where(:site_id => @site.id, :username => 'elo').first
90
+ vl = Caboose::VariantLimit.where(:user_id => elo.id, :variant_id => v.id).first if elo && v
87
91
  %>
88
92
  var vcc = false;
89
93
  $(document).ready(function() {
@@ -100,36 +104,38 @@ $(document).ready(function() {
100
104
  update_url: '/admin/products/<%= v.product_id %>/variants/<%= v.id %>',
101
105
  authenticity_token: '<%= form_authenticity_token %>',
102
106
  attributes: [
103
- <% if p.option1 %>{ name: 'option1' , nice_name: <%= raw Caboose.json(p.option1) %> , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.option1 ) %> },<% end %>
104
- <% if p.option2 %>{ name: 'option2' , nice_name: <%= raw Caboose.json(p.option2) %> , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.option2 ) %> },<% end %>
105
- <% if p.option3 %>{ name: 'option3' , nice_name: <%= raw Caboose.json(p.option3) %> , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.option3 ) %> },<% end %>
106
- { name: 'alternate_id' , nice_name: 'Alternate ID' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.alternate_id ) %> },
107
- { name: 'sku' , nice_name: 'SKU' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.sku ) %> },
108
- { name: 'barcode' , nice_name: 'Barcode' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.barcode ) %> },
109
- { name: 'cost' , nice_name: 'Cost of Goods' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(sprintf("%.2f", v.cost) ) %> },
110
- { name: 'price' , nice_name: 'Price' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(sprintf("%.2f", v.price) ) %> },
111
- { name: 'sale_price' , nice_name: 'Sale price' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.sale_price ) %> },
112
- { name: 'date_sale_starts' , nice_name: 'Sale starts' , type: 'datetime' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.date_sale_starts ? v.date_sale_starts.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
113
- { name: 'date_sale_ends' , nice_name: 'Sale ends' , type: 'datetime' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.date_sale_ends ? v.date_sale_ends.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
114
- { name: 'clearance' , nice_name: 'On Clearance' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.clearance ) %> },
115
- { name: 'clearance_price' , nice_name: 'Clearance price' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.clearance_price ) %> },
116
- { name: 'quantity_in_stock' , nice_name: 'Quantity' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.quantity_in_stock ) %> },
117
- { name: 'ignore_quantity' , nice_name: 'Ignore Quantity' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.ignore_quantity ) %> },
118
- { name: 'weight' , nice_name: 'Weight (<%= sc.weight_unit %>)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.weight ) %> },
119
- { name: 'length' , nice_name: 'Length (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.length ) %> },
120
- { name: 'width' , nice_name: 'Width (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.width ) %> },
121
- { name: 'height' , nice_name: 'Height (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.height ) %> },
122
- { name: 'cylinder' , nice_name: 'Cylinder' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.cylinder ) %> },
123
- { name: 'requires_shipping' , nice_name: 'Requires shipping' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.requires_shipping ) %> },
124
- { name: 'taxable' , nice_name: 'Taxable' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.taxable ) %> },
125
- { name: 'allow_backorder' , nice_name: 'Allow backorder' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.allow_backorder ) %> },
126
- { name: 'status' , nice_name: 'Status' , type: 'select' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.status ) %>, options_url: '/admin/variants/status-options' },
127
- { name: 'downloadable' , nice_name: 'Downloadable' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.downloadable ) %> },
128
- { name: 'download_path' , nice_name: 'Download path' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.download_path ) %> },
129
- { name: 'flat_rate_shipping' , nice_name: 'Use flat rate shipping' , type: 'checkbox' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.flat_rate_shipping ) %> },
130
- { name: 'flat_rate_shipping_single' , nice_name: 'Amount (single)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.flat_rate_shipping_single ) %> },
131
- { name: 'flat_rate_shipping_combined' , nice_name: 'Amount (combined)' , type: 'text' , align: 'right' , width: 500, value: <%= raw Caboose.json(v.flat_rate_shipping_combined ) %> },
132
- { name: 'flat_rate_shipping_package_method_id' , nice_name: 'Package method' , type: 'select' , align: 'right' , width: 500, options_url: '/admin/shipping-packages/package-method-options',
107
+ <% if p.option1 %>{ name: 'option1' , nice_name: <%= raw Caboose.json(p.option1) %> , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.option1 ) %> },<% end %>
108
+ <% if p.option2 %>{ name: 'option2' , nice_name: <%= raw Caboose.json(p.option2) %> , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.option2 ) %> },<% end %>
109
+ <% if p.option3 %>{ name: 'option3' , nice_name: <%= raw Caboose.json(p.option3) %> , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.option3 ) %> },<% end %>
110
+ { name: 'alternate_id' , nice_name: 'Alternate ID' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.alternate_id ) %> },
111
+ { name: 'sku' , nice_name: 'SKU' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.sku ) %> },
112
+ { name: 'barcode' , nice_name: 'Barcode' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.barcode ) %> },
113
+ { name: 'cost' , nice_name: 'Cost of Goods' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(sprintf("%.2f", v.cost) ) %> },
114
+ { name: 'price' , nice_name: 'Price' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(sprintf("%.2f", v.price) ) %> },
115
+ { name: 'sale_price' , nice_name: 'Sale price' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.sale_price ) %> },
116
+ { name: 'date_sale_starts' , nice_name: 'Sale starts' , type: 'datetime' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.date_sale_starts ? v.date_sale_starts.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
117
+ { name: 'date_sale_ends' , nice_name: 'Sale ends' , type: 'datetime' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.date_sale_ends ? v.date_sale_ends.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
118
+ { name: 'clearance' , nice_name: 'On Clearance' , type: 'checkbox' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.clearance ) %> },
119
+ { name: 'clearance_price' , nice_name: 'Clearance price' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.clearance_price ) %> },
120
+ { name: 'quantity_in_stock' , nice_name: 'Quantity' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.quantity_in_stock ) %> },
121
+ { name: 'ignore_quantity' , nice_name: 'Ignore Quantity' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.ignore_quantity ) %> },
122
+ { name: 'max_quantity_value' , nice_name: 'Max Quantity per User' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(vl && vl.max_quantity_value ? vl.max_quantity_value : '' ) %>, update_url: '/admin/variant-limits/<%== vl ? vl.id : "new/#{v.id}" %>' },
123
+ { name: 'min_quantity_value' , nice_name: 'Min Quantity per User' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(vl && vl.min_quantity_value ? vl.min_quantity_value : '' ) %>, update_url: '/admin/variant-limits/<%== vl ? vl.id : "new/#{v.id}" %>' },
124
+ { name: 'weight' , nice_name: 'Weight (<%= sc.weight_unit %>)' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.weight ) %> },
125
+ { name: 'length' , nice_name: 'Length (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.length ) %> },
126
+ { name: 'width' , nice_name: 'Width (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.width ) %> },
127
+ { name: 'height' , nice_name: 'Height (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.height ) %> },
128
+ { name: 'cylinder' , nice_name: 'Cylinder' , type: 'checkbox' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.cylinder ) %> },
129
+ { name: 'requires_shipping' , nice_name: 'Requires shipping' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.requires_shipping ) %> },
130
+ { name: 'taxable' , nice_name: 'Taxable' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.taxable ) %> },
131
+ { name: 'allow_backorder' , nice_name: 'Allow backorder' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.allow_backorder ) %> },
132
+ { name: 'status' , nice_name: 'Status' , type: 'select' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.status ) %>, options_url: '/admin/variants/status-options' },
133
+ { name: 'downloadable' , nice_name: 'Downloadable' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.downloadable ) %> },
134
+ { name: 'download_path' , nice_name: 'Download path' , type: 'text' , align: 'right' , width: 800, value: <%= raw Caboose.json(v.download_path ) %> },
135
+ { name: 'flat_rate_shipping' , nice_name: 'Use flat rate shipping' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.flat_rate_shipping ) %> },
136
+ { name: 'flat_rate_shipping_single' , nice_name: 'Amount (single)' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.flat_rate_shipping_single ) %> },
137
+ { name: 'flat_rate_shipping_combined' , nice_name: 'Amount (combined)' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.flat_rate_shipping_combined ) %> },
138
+ { name: 'flat_rate_shipping_package_method_id' , nice_name: 'Package method' , type: 'select' , align: 'right' , width: 250, options_url: '/admin/shipping-packages/package-method-options',
133
139
  value: <%= raw Caboose.json("#{v.flat_rate_shipping_package_id}_#{v.flat_rate_shipping_method_id}") %>,
134
140
  text: <%= raw Caboose.json(v.flat_rate_shipping_package && v.flat_rate_shipping_method ? "#{v.flat_rate_shipping_package.name} - #{v.flat_rate_shipping_method.service_name}" : '') %>
135
141
  },
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.9.31'
2
+ VERSION = '0.9.32'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.31
4
+ version: 0.9.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry