caboose-store 0.0.11 → 0.0.12

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.
Files changed (32) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose_store/application.js +0 -2
  3. data/app/assets/javascripts/caboose_store/checkout.js +143 -143
  4. data/app/assets/javascripts/caboose_store/modules/checkout.js +31 -32
  5. data/app/assets/javascripts/caboose_store/modules/checkout_step1.js +157 -0
  6. data/app/assets/javascripts/caboose_store/modules/checkout_step2.js +39 -0
  7. data/app/assets/javascripts/caboose_store/modules/checkout_step3.js +34 -0
  8. data/app/assets/javascripts/caboose_store/modules/checkout_step4.js +102 -0
  9. data/app/assets/templates/caboose_store/checkout/forms/guest.jst.ejs +1 -1
  10. data/app/assets/templates/caboose_store/checkout/forms/register.jst.ejs +1 -1
  11. data/app/assets/templates/caboose_store/checkout/forms/signin.jst.ejs +1 -1
  12. data/app/assets/templates/caboose_store/checkout/line_items.jst.ejs +1 -2
  13. data/app/assets/templates/caboose_store/checkout/login.jst.ejs +4 -4
  14. data/app/controllers/caboose_store/checkout_controller.rb +108 -46
  15. data/app/helpers/caboose_store/checkout_helper.rb +15 -0
  16. data/app/models/caboose_store/schema.rb +4 -0
  17. data/app/models/caboose_store/states.rb +66 -0
  18. data/app/views/caboose_store/cart/index.html.erb +4 -0
  19. data/app/views/caboose_store/checkout/_confirm.html.erb +61 -0
  20. data/app/views/caboose_store/checkout/index.html.erb +1 -1
  21. data/app/views/caboose_store/checkout/relay.html.erb +2 -2
  22. data/app/views/caboose_store/checkout/relay_old.html.erb +12 -0
  23. data/app/views/caboose_store/checkout/step_four.html.erb +91 -0
  24. data/app/views/caboose_store/checkout/step_one.html.erb +46 -11
  25. data/app/views/caboose_store/checkout/step_one_old.html.erb +13 -0
  26. data/app/views/caboose_store/checkout/step_three.html.erb +23 -0
  27. data/app/views/caboose_store/checkout/step_two.html.erb +49 -13
  28. data/app/views/caboose_store/checkout/step_two_old.html.erb +14 -0
  29. data/app/views/caboose_store/products/details.html.erb +2 -0
  30. data/config/routes.rb +10 -7
  31. data/lib/caboose-store/version.rb +1 -1
  32. metadata +13 -2
@@ -27,5 +27,20 @@ module CabooseStore
27
27
  def caboose_store_billing_form
28
28
  render :partial => '/caboose_store/checkout/billing_form'
29
29
  end
30
+
31
+ def checkout_nav(i)
32
+ str = ""
33
+ str << "<div id='nav'>"
34
+ str << " <ul>"
35
+ str << " <li class='odd' id='checkout_nav1'><a href='#{i <= 1 ? '#' : '/checkout/step-one' }' class='#{i == 1 ? 'current' : (i < 1 ? 'not_done' : 'done')}'><span>User Account </span></a></li>"
36
+ str << " <li class='even' id='checkout_nav2'><a href='#{i <= 2 ? '#' : '/checkout/step-two' }' class='#{i == 2 ? 'current' : (i < 2 ? 'not_done' : 'done')}'><span>Addresses </span></a></li>"
37
+ str << " <li class='odd' id='checkout_nav3'><a href='#{i <= 3 ? '#' : '/checkout/step-three' }' class='#{i == 3 ? 'current' : (i < 3 ? 'not_done' : 'done')}'><span>Shipping </span></a></li>"
38
+ str << " <li class='even' id='checkout_nav4'><a href='#{i <= 4 ? '#' : '/checkout/step-four' }' class='#{i == 4 ? 'current' : (i < 4 ? 'not_done' : 'done')}'><span>Payment </span></a></li>"
39
+ str << " <li class='odd' id='checkout_nav5'><a href='#{i <= 5 ? '#' : '/checkout/step-five' }' class='#{i == 5 ? 'current' : (i < 5 ? 'not_done' : 'done')}'><span>Confirm </span></a></li>"
40
+ str << " </ul>"
41
+ str << "</div>"
42
+ return str
43
+ end
44
+
30
45
  end
31
46
  end
@@ -3,6 +3,10 @@ class CabooseStore::Schema < Caboose::Utilities::Schema
3
3
 
4
4
  def self.schema
5
5
  {
6
+ Caboose::User => [
7
+ [ :is_guest , :boolean , { :default => false }]
8
+ ],
9
+
6
10
  CabooseStore::Address => [
7
11
  [ :name , :string ],
8
12
  [ :first_name , :string ],
@@ -0,0 +1,66 @@
1
+ class States
2
+ def self.all
3
+ {
4
+ "AL" => "Alabama",
5
+ "AK" => "Alaska",
6
+ "AS" => "American Samoa",
7
+ "AZ" => "Arizona",
8
+ "AR" => "Arkansas",
9
+ "CA" => "California",
10
+ "CO" => "Colorado",
11
+ "CT" => "Connecticut",
12
+ "DE" => "Delaware",
13
+ "DC" => "District Of Columbia",
14
+ "FM" => "Federated States Of Micronesia",
15
+ "FL" => "Florida",
16
+ "GA" => "Georgia",
17
+ "GU" => "Guam",
18
+ "HI" => "Hawaii",
19
+ "ID" => "Idaho",
20
+ "IL" => "Illinois",
21
+ "IN" => "Indiana",
22
+ "IA" => "Iowa",
23
+ "KS" => "Kansas",
24
+ "KY" => "Kentucky",
25
+ "LA" => "Louisiana",
26
+ "ME" => "Maine",
27
+ "MH" => "Marshall Islands",
28
+ "MD" => "Maryland",
29
+ "MA" => "Massachusetts",
30
+ "MI" => "Michigan",
31
+ "MN" => "Minnesota",
32
+ "MS" => "Mississippi",
33
+ "MO" => "Missouri",
34
+ "MT" => "Montana",
35
+ "NE" => "Nebraska",
36
+ "NV" => "Nevada",
37
+ "NH" => "New Hampshire",
38
+ "NJ" => "New Jersey",
39
+ "NM" => "New Mexico",
40
+ "NY" => "New York",
41
+ "NC" => "North Carolina",
42
+ "ND" => "North Dakota",
43
+ "MP" => "Northern Mariana Islands",
44
+ "OH" => "Ohio",
45
+ "OK" => "Oklahoma",
46
+ "OR" => "Oregon",
47
+ "PW" => "Palau",
48
+ "PA" => "Pennsylvania",
49
+ "PR" => "Puerto Rico",
50
+ "RI" => "Rhode Island",
51
+ "SC" => "South Carolina",
52
+ "SD" => "South Dakota",
53
+ "TN" => "Tennessee",
54
+ "TX" => "Texas",
55
+ "UT" => "Utah",
56
+ "VT" => "Vermont",
57
+ "VI" => "Virgin Islands",
58
+ "VA" => "Virginia",
59
+ "WA" => "Washington",
60
+ "WV" => "West Virginia",
61
+ "WI" => "Wisconsin",
62
+ "WY" => "Wyoming"
63
+ }
64
+ end
65
+ end
66
+
@@ -2,3 +2,7 @@
2
2
  <div id="cart"></div>
3
3
  </div>
4
4
 
5
+ <% content_for :caboose_js do %>
6
+ <%= javascript_include_tag 'caboose_store/modules/cart' %>
7
+ <%= javascript_include_tag 'caboose_store/modules/product' %>
8
+ <% end %>
@@ -0,0 +1,61 @@
1
+ <section id='checkout-confirm'>
2
+ <div class='wrapper'>
3
+ <section id="line-items">
4
+ <table>
5
+ <tr>
6
+ <th>Product</th>
7
+ <th>Quantity</th>
8
+ <th>Unit Price</th>
9
+ <th>Subtotal</th>
10
+ </tr>
11
+ <% @order.line_items.each do |li| %>
12
+ <tr data-id="<%= li.id %>">
13
+ <td valign='top'>
14
+ <% if li.variant.product_images.count > 0 %>
15
+ <figure style="background-image: url(<%= li.variant.product_images[0].image.url(:thumb) %>)"></figure>
16
+ <% end %>
17
+ <p><%= li.title %></p>
18
+ </td>
19
+ <td valign='top' align='right' class='qty' ><%= li.quantity %></td>
20
+ <td valign='top' align='right' class='price' ><%= number_to_currency(li.price, :precision => 2) %></td>
21
+ <td valign='top' align='right' class='subtotal'><%= number_to_currency(li.price, :precision => 2) %></td>
22
+ </tr>
23
+ <% end %>
24
+ <tr><td colspan='3' align='right'>Subtotal: </td><td align='right'><%= number_to_currency(@order.subtotal, :precision => 2) %></td></tr>
25
+ <tr><td colspan='3' align='right'>Shipping & Handling: </td><td align='right'><%= number_to_currency(@order.shipping + @order.handling, :precision => 2) %></td></tr>
26
+ <% if @order.tax > 0 && @order.billing_address.state == 'AL' %>
27
+ <tr><td colspan='3' align='right'>Tax <small>(if in Alabama)</small>: </td><td align='right'><%= number_to_currency(@order.tax, :precision => 2) %></td></tr>
28
+ <% end %>
29
+ <tr><td colspan='3' align='right'>Total: </td><td align='right'><%= number_to_currency(@order.total, :precision => 2) %></td></tr>
30
+ </table>
31
+ </section>
32
+ <section id='shipping_address'>
33
+ <% sa = @order.shipping_address %>
34
+ <address>
35
+ <%= "#{sa.first_name} #{sa.last_name}" %><br />
36
+ <%= sa.address1 %><br />
37
+ <%= "#{sa.address2}<br />" if sa.address2 and not sa.address2.empty? %>
38
+ <%= "#{sa.city}, #{sa.state} #{sa.zip}" %>
39
+ </address>
40
+ <p><a href="/checkout/step-two">Edit shipping address</a></p>
41
+ </section>
42
+ <section id='billing_address'>
43
+ <% ba = @order.billing_address %>
44
+ <address>
45
+ <%= "#{ba.first_name} #{ba.last_name}" %><br />
46
+ <%= ba.address1 %><br />
47
+ <%= "#{ba.address2}<br />" if ba.address2 and not ba.address2.empty? %>
48
+ <%= "#{ba.city}, #{ba.state} #{ba.zip}" %>
49
+ </address>
50
+ <p><a href="/checkout/step-two">Edit billing address</a></p>
51
+ </section>
52
+ <section id='shipping_method'>
53
+ <p><%= @order.shipping_method %> - <%= number_to_currency(@order.shipping) %></p>
54
+ <p><a href="/checkout/step-three">Edit shipping method</a></p>
55
+ </section>
56
+ <section id='payment_method'>
57
+ <p id='confirm_card_number'></p>
58
+ <p><a href="#" id='edit_payment'>Edit payment</a></p>
59
+ </section>
60
+ </div>
61
+ </section>
@@ -1,4 +1,4 @@
1
- <h3>Checkout</h3>
1
+ <h3>Checkout2</h3>
2
2
  <%= caboose_store_cart %>
3
3
  <%= caboose_store_address_form %>
4
4
 
@@ -2,10 +2,10 @@
2
2
  <html>
3
3
  <body>
4
4
  <script id="response" type="application/json">
5
- {
5
+ parent.relay_handler({
6
6
  "success": <%= @success %>,
7
7
  "message": "<%= @message %>"
8
- }
8
+ });
9
9
  </script>
10
10
  </body>
11
11
  </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE>
2
+ <html>
3
+ <body>
4
+ <script id="response" type="application/json">
5
+ {
6
+ "success": <%= @success %>,
7
+ "message": "<%= @message %>"
8
+ }
9
+ </script>
10
+ </body>
11
+ </html>
12
+
@@ -0,0 +1,91 @@
1
+
2
+ <div id="checkout">
3
+ <h2>Checkout</h2>
4
+ <%= raw checkout_nav(4) %>
5
+ <%= render :partial => 'caboose_store/checkout/confirm' %>
6
+ <section id="checkout-payment">
7
+ <div class="wrapper">
8
+ <% if CabooseStore::payment_processor == 'authorize.net' %>
9
+ <form id="payment" target="relay" action="<%= CabooseStore::PaymentProcessor.form_url(@order) %>" method="post">
10
+ <%= sim_fields(@sim_transaction) %>
11
+ <label>Card Number</label>
12
+ <input name="x_card_num" type="text" />
13
+ <label>Expiration</label>
14
+ <input id="expiration" name="x_exp_date" type="hidden" />
15
+ <br />
16
+ <select id="month" name="month">
17
+ <option value="01">01 - Jan</option>
18
+ <option value="02">02 - Feb</option>
19
+ <option value="03">03 - Mar</option>
20
+ <option value="04">04 - Apr</option>
21
+ <option value="05">05 - May</option>
22
+ <option value="06">06 - Jun</option>
23
+ <option value="07">07 - Jul</option>
24
+ <option value="08">08 - Aug</option>
25
+ <option value="09">09 - Sep</option>
26
+ <option value="10">10 - Oct</option>
27
+ <option value="11">11 - Nov</option>
28
+ <option value="12">12 - Dec</option>
29
+ </select>
30
+ /
31
+ <select id="year" name="year">
32
+ <% (DateTime.now.year...DateTime.now.year + 20).each do |i| %>
33
+ <option value="<%= i-2000 %>"><%= i %></option>
34
+ <% end %>
35
+ </select>
36
+ <br />
37
+ <label>Security Code</label>
38
+ <input id="x_card_code" name="x_card_code" type="text" />
39
+ <input type="submit" value="Submit" />
40
+ </form>
41
+ <% end %>
42
+
43
+ <% if CabooseStore::payment_processor == 'payscape' %>
44
+ <form id="payment" action="<%= @form_url %>" method="post" target="relay">
45
+ <input id="billing-amount" type="hidden" value="<%= @order.total %>" />
46
+ <input id="expiration" name="billing-cc-exp" type="hidden" />
47
+ <div>
48
+ <label for="billing-cc-number">Card number:</label>
49
+ <input id="billing-cc-number" name="billing-cc-number" type="text" maxlength="16" />
50
+ </div>
51
+ <div>
52
+ <label for="billing-expiration-month">Expiration:</label>
53
+ <select name="month">
54
+ <option value="01">01 - Jan</option>
55
+ <option value="02">02 - Feb</option>
56
+ <option value="03">03 - Mar</option>
57
+ <option value="04">04 - Apr</option>
58
+ <option value="05">05 - May</option>
59
+ <option value="06">06 - Jun</option>
60
+ <option value="07">07 - Jul</option>
61
+ <option value="08">08 - Aug</option>
62
+ <option value="09">09 - Sep</option>
63
+ <option value="10">10 - Oct</option>
64
+ <option value="11">11 - Nov</option>
65
+ <option value="12">12 - Dec</option>
66
+ </select>
67
+ /
68
+ <select name="year">
69
+ <% (DateTime.now.year...DateTime.now.year + 20).each do |i| %>
70
+ <option value="<%= i-2000 %>"><%= i %></option>
71
+ <% end %>
72
+ </select>
73
+ </div>
74
+
75
+ <!--<input type="submit" value="Submit" />-->
76
+ </form>
77
+ <% end %>
78
+ </div>
79
+ </section>
80
+ <section id="checkout-continue">
81
+ <div id='message'></div>
82
+ <button class="blue">Continue</button>
83
+ <em>or</em>
84
+ <a href="/">return to the store</a>
85
+ </section>
86
+ <iframe id="relay" name="relay"></iframe>
87
+ </div>
88
+
89
+ <%= content_for :caboose_js do %>
90
+ <%= javascript_include_tag 'caboose_store/modules/checkout_step4' %>
91
+ <% end %>
@@ -1,15 +1,50 @@
1
- <div id="checkout" class="loading">
2
- <header>Thanks for shopping with Expeditions</header>
3
- <section id="checkout-line-items"></section>
4
- <h3><span>step 1 of 2</span></h3>
5
- <figure class="loading"></figure>
6
- <section id="checkout-login"></section>
7
- <section id="checkout-address"></section>
1
+ <div id="checkout">
2
+ <h2>Checkout</h2>
3
+ <%= raw checkout_nav(1) %>
8
4
 
9
- <section id="checkout-continue">
10
- <button class="blue">Continue</button>
11
- <em>or</em>
5
+ <section id="checkout-login">
6
+ <div class="wrapper" class='login-choices'>
7
+ <ul>
8
+ <li><p>Already a member </p><button data-login-action="signin" id='signin_button' >Sign in</button></li>
9
+ <li><p>Sign up for all of our member benefits </p><button data-login-action="register" id='register_button' >New Customer</button></li>
10
+ <li><p>No thanks </p><button data-login-action="guest" id='guest_button' >Continue As Guest</button></li>
11
+ </ul>
12
+ </div>
13
+ <section id='checkout-login-form'>
14
+ <div class="wrapper" id='signin_form_container'>
15
+ <form action="/login" method="post" id='signin_form'>
16
+ <input name="username" type="text" placeholder="Email" />
17
+ <input name="password" type="password" placeholder="Password" />
18
+ <input type="submit" value="Submit" />
19
+ </form>
20
+ </div>
21
+ <div class="wrapper" id='register_form_container'>
22
+ <form action="/register" method="post" id='register_form'>
23
+ <input name="first_name" type="text" placeholder="First Name" />
24
+ <input name="last_name" type="text" placeholder="Last Name" />
25
+ <input name="email" type="text" placeholder="Email" />
26
+ <input name="phone" type="text" placeholder="Phone" />
27
+ <input name="pass1" type="password" placeholder="Password" />
28
+ <input name="pass2" type="password" placeholder="Confirm Password" />
29
+ <input type="submit" value="Submit" />
30
+ </form>
31
+ </div>
32
+ <div class="wrapper" id='guest_form_container'>
33
+ <form action="/checkout/attach-guest" method="post" id='guest_form'>
34
+ <input name="email" type="text" placeholder="Email" />
35
+ <input name="confirm_email" type="email" placeholder="Confirm email" />
36
+ <input type="submit" value="Submit" />
37
+ </form>
38
+ </div>
39
+ <div id='message'></div>
40
+ </section>
41
+ </section>
42
+
43
+ <section id="checkout-continue">
12
44
  <a href="/">return to the store</a>
13
45
  </section>
14
46
  </div>
15
-
47
+
48
+ <%= content_for :caboose_js do %>
49
+ <%= javascript_include_tag 'caboose_store/modules/checkout_step1' %>
50
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <div id="checkout" class="loading">
2
+ <header>Checkout Step 1 of 3</header>
3
+ <section id="checkout-line-items"></section>
4
+ <figure class="loading"></figure>
5
+ <section id="checkout-login"></section>
6
+ <section id="checkout-address"></section>
7
+
8
+ <section id="checkout-continue">
9
+ <button class="blue">Continue</button>
10
+ <em>or</em>
11
+ <a href="/">return to the store</a>
12
+ </section>
13
+ </div>
@@ -0,0 +1,23 @@
1
+ <div id="checkout">
2
+ <h2>Checkout</h2>
3
+ <%= raw checkout_nav(3) %>
4
+ <section id="checkout-shipping">
5
+ <div class="wrapper">
6
+ <p>Please select how you would like your products to be delivered</p>
7
+ <% @rates.each do |rate| %>
8
+ <button class="blue" data-shipping-code="<%= rate[:service_code] %>" data-shipping-method="<%= rate[:service_name] %>">
9
+ <%= number_to_currency(rate[:total_price], :precision => 2) %><br /><%= rate[:service_name] %>
10
+ </button>
11
+ <% end %>
12
+ </select>
13
+ </div>
14
+ </section>
15
+ <section id="checkout-continue">
16
+ <div id='message'></div>
17
+ <a href="/">return to the store</a>
18
+ </section>
19
+ </div>
20
+
21
+ <%= content_for :caboose_js do %>
22
+ <%= javascript_include_tag 'caboose_store/modules/checkout_step3' %>
23
+ <% end %>
@@ -1,15 +1,51 @@
1
- <div id="checkout" class="loading">
2
- <header>Thanks for shopping with Expeditions</header>
3
- <h3><span>step 2 of 2</span></h3>
4
- <figure class="loading"></figure>
5
- <section id="checkout-shipping"></section>
6
- <section id="checkout-line-items"></section>
7
- <section id="checkout-payment"></section>
8
-
9
- <section id="checkout-complete">
10
- <button class="blue">Complete my Purchase</button>
11
- <em>or</em>
12
- <a href="/">return to the store</a>
13
- </section>
1
+ <%
2
+ sa = @order.shipping_address
3
+ ba = @order.billing_address
4
+ %>
5
+ <div id="checkout">
6
+ <h2>Checkout</h2>
7
+ <%= raw checkout_nav(2) %>
8
+ <form action="/checkout/address" method="put" id='address_form'>
9
+ <section id="checkout-address">
10
+ <div class="wrapper">
11
+ <section>
12
+ <fieldset id="shipping">
13
+ <h3>Shipping Address</h3>
14
+ <label><span>First Name </span> <input name="shipping[first_name]" type="text" value="<%= sa ? sa.first_name : "" %>" /></label>
15
+ <label><span>Last Name </span> <input name="shipping[last_name]" type="text" value="<%= sa ? sa.last_name : "" %>" /></label>
16
+ <label><span>Company </span> <input name="shipping[company]" type="text" value="<%= sa ? sa.company : "" %>" /></label>
17
+ <label><span>Address 1 </span> <input name="shipping[address1]" type="text" value="<%= sa ? sa.address1 : "" %>" /></label>
18
+ <label><span>Address 2 </span> <input name="shipping[address2]" type="text" value="<%= sa ? sa.address2 : "" %>" /></label>
19
+ <label><span>City </span> <input name="shipping[city]" type="text" value="<%= sa ? sa.city : "" %>" /></label>
20
+ <label><span>State </span> <select name="shipping[state]"><% States.all.each do |abbr, state| %><option value="<%= abbr %>" <%= sa && sa.state == abbr ? 'selected' : "" %>><%= state %></option><% end %></select></label>
21
+ <label><span>Zip </span> <input name="shipping[zip]" type="text" value="<%= sa ? sa.zip : "" %>" /></label>
22
+ <label><input name="use_as_billing" type="checkbox" value="false" /> Use as billing address</label>
23
+ </fieldset>
24
+ </section>
25
+ <section>
26
+ <fieldset id="billing">
27
+ <h3>Billing Address</h3>
28
+ <label><span>First Name </span> <input name="billing[first_name]" type="text" value="<%= ba ? ba.first_name : "" %>" /></label>
29
+ <label><span>Last Name </span> <input name="billing[last_name]" type="text" value="<%= ba ? ba.last_name : "" %>" /></label>
30
+ <label><span>Company </span> <input name="billing[company]" type="text" value="<%= ba ? ba.company : "" %>" /></label>
31
+ <label><span>Address 1 </span> <input name="billing[address1]" type="text" value="<%= ba ? ba.address1 : "" %>" /></label>
32
+ <label><span>Address 2 </span> <input name="billing[address2]" type="text" value="<%= ba ? ba.address2 : "" %>" /></label>
33
+ <label><span>City </span> <input name="billing[city]" type="text" value="<%= ba ? ba.city : "" %>" /></label>
34
+ <label><span>State </span> <select name="billing[state]"><% States.all.each do |abbr, state| %><option value="<%= abbr %>" <%= ba && ba.state == abbr ? 'selected' : "" %>><%= state %></option><% end %></select></label>
35
+ <label><span>Zip </span> <input name="billing[zip]" type="text" value="<%= ba ? ba.zip : "" %>" /></label>
36
+ </fieldset>
37
+ </section>
38
+ </div>
39
+ </section>
40
+ <section id="checkout-continue">
41
+ <div id='message'></div>
42
+ <button class="blue">Continue</button>
43
+ <em>or</em>
44
+ <a href="/">return to the store</a>
45
+ </section>
46
+ </form>
14
47
  </div>
15
48
 
49
+ <%= content_for :caboose_js do %>
50
+ <%= javascript_include_tag 'caboose_store/modules/checkout_step2' %>
51
+ <% end %>