piggybak_coupons 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/piggybak_coupons/piggybak_coupons.js +10 -2
- data/app/models/piggybak_coupons/coupon.rb +6 -0
- data/lib/piggybak_coupons/version.rb +1 -1
- metadata +4 -6
- data/app/assets/stylesheets/piggybak_coupons/application.css +0 -13
- data/app/views/layouts/piggybak_coupons/application.html.erb +0 -14
@@ -2,9 +2,17 @@ $(function() {
|
|
2
2
|
$('#coupon_code').change(function() {
|
3
3
|
$(this).data('changed', true);
|
4
4
|
});
|
5
|
-
|
5
|
+
piggybak.shipping_els.live('change', function() {
|
6
|
+
if($('#coupon_code').val() != '') {
|
7
|
+
setTimeout(function() {
|
8
|
+
$('#coupon_code').data('changed', true);
|
9
|
+
piggybak_coupons.apply_coupon(false);
|
10
|
+
}, 500);
|
11
|
+
}
|
12
|
+
});
|
13
|
+
$('#shipping select').live('change', function() {
|
14
|
+
$('#coupon_code').data('changed', true);
|
6
15
|
piggybak_coupons.apply_coupon(false);
|
7
|
-
return false;
|
8
16
|
});
|
9
17
|
$('#apply_coupon').click(function() {
|
10
18
|
piggybak_coupons.apply_coupon(false);
|
@@ -14,6 +14,12 @@ module PiggybakCoupons
|
|
14
14
|
validates_numericality_of :allowed_applications, :greater_than_or_equal_to => 0
|
15
15
|
validate :validate_dollar_discount
|
16
16
|
|
17
|
+
after_initialize :generate_code, :if => Proc.new { |giftcert| giftcert.new_record? }
|
18
|
+
def generate_code
|
19
|
+
# TODO: Replace 12 with configurable giftcert code length
|
20
|
+
self.code = (0...12).map{65.+(rand(26)).chr}.join
|
21
|
+
end
|
22
|
+
|
17
23
|
def validate_dollar_discount
|
18
24
|
if self.discount_type == "$" && self.amount > self.min_cart_total
|
19
25
|
self.errors.add(:min_cart_total, "Minimum cart total must be greater than amount for dollar discount.")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak_coupons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -35,11 +35,9 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- app/controllers/piggybak_coupons/coupon_controller.rb
|
38
|
-
- app/assets/stylesheets/piggybak_coupons/application.css
|
39
38
|
- app/assets/javascripts/piggybak_coupons/piggybak_coupons.js
|
40
39
|
- app/models/piggybak_coupons/coupon_application.rb
|
41
40
|
- app/models/piggybak_coupons/coupon.rb
|
42
|
-
- app/views/layouts/piggybak_coupons/application.html.erb
|
43
41
|
- app/views/piggybak_coupons/_apply_coupon.html.erb
|
44
42
|
- config/routes.rb
|
45
43
|
- db/migrate/20121012220537_piggybak_coupons_setup.rb
|
@@ -97,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
95
|
version: '0'
|
98
96
|
segments:
|
99
97
|
- 0
|
100
|
-
hash:
|
98
|
+
hash: 623399165070746312
|
101
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
100
|
none: false
|
103
101
|
requirements:
|
@@ -106,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
104
|
version: '0'
|
107
105
|
segments:
|
108
106
|
- 0
|
109
|
-
hash:
|
107
|
+
hash: 623399165070746312
|
110
108
|
requirements: []
|
111
109
|
rubyforge_project:
|
112
110
|
rubygems_version: 1.8.23
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>PiggybakCoupons</title>
|
5
|
-
<%= stylesheet_link_tag "piggybak_coupons/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "piggybak_coupons/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|