Skip to content

Commit

Permalink
Added JS alert when adding more than available.
Browse files Browse the repository at this point in the history
  • Loading branch information
mud committed Apr 3, 2012
1 parent 24caf34 commit 3afc958
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/assets/javascripts/store/spree_limit_quantity.js
@@ -1 +1,11 @@
//= require store/spree_core
(function($) {
$(function() {
$('input[type="number"]').on('blur', function() {
var $this = $(this);
if ($this.attr('max') && parseInt($this.attr('max')) < $this.attr('value')) {
$this.attr('value', $this.attr('max'));
alert('There are only ' + $this.attr('max') + ' items available for this product.');
}
});
});
})(jQuery);
3 changes: 2 additions & 1 deletion app/overrides/show_qty_limit.rb
@@ -1,4 +1,5 @@
Deface::Override.new(:virtual_path => "spree/products/_cart_form",
:name => "add_qty_limit",
:insert_after => "div.add-to-cart",
:text => '<% if @product.quantity_limited? %><p>Order Limit: <%= @product.quantity_limit_value %></p><% end %>')
:text => '<% if @product.quantity_limited? %><p>Order Limit: <%= @product.quantity_limit_value %></p><% end %>',
:sequence => 201)

0 comments on commit 3afc958

Please sign in to comment.