caboose-store 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/main.js +8 -0
  3. data/app/assets/javascripts/caboose_store/admin.js +0 -19
  4. data/app/assets/javascripts/caboose_store/admin_products.js +3 -4
  5. data/app/assets/javascripts/caboose_store/application.js +6 -5
  6. data/app/assets/javascripts/caboose_store/cart.js.bak +258 -0
  7. data/app/assets/javascripts/caboose_store/checkout.js +151 -0
  8. data/app/assets/javascripts/caboose_store/config.js +83 -0
  9. data/app/assets/javascripts/caboose_store/jquery-ui-multisortable.js +254 -0
  10. data/app/assets/javascripts/caboose_store/jquery-ui.js +3572 -0
  11. data/app/assets/javascripts/caboose_store/main.js +20 -0
  12. data/app/assets/javascripts/caboose_store/modules/cart.js +167 -0
  13. data/app/assets/javascripts/caboose_store/modules/checkout.js +313 -0
  14. data/app/assets/javascripts/caboose_store/modules/product.js +282 -0
  15. data/app/assets/stylesheets/caboose_store/admin.css +3 -3
  16. data/app/assets/stylesheets/caboose_store/application.css +2 -2
  17. data/app/assets/stylesheets/caboose_store/modal.css +1 -0
  18. data/app/assets/templates/caboose_store/cart/add_to_cart.jst.ejs +7 -0
  19. data/app/assets/templates/caboose_store/cart/line_items.jst.ejs +41 -0
  20. data/app/assets/templates/caboose_store/checkout/address.jst.ejs +53 -0
  21. data/app/assets/templates/caboose_store/checkout/forms/guest.jst.ejs +8 -0
  22. data/app/assets/templates/caboose_store/checkout/forms/register.jst.ejs +11 -0
  23. data/app/assets/templates/caboose_store/checkout/forms/signin.jst.ejs +7 -0
  24. data/app/assets/templates/caboose_store/checkout/line_items.jst.ejs +32 -0
  25. data/app/assets/templates/caboose_store/checkout/login.jst.ejs +21 -0
  26. data/app/assets/templates/caboose_store/checkout/payment.jst.ejs +5 -0
  27. data/app/assets/templates/caboose_store/checkout/shipping.jst.ejs +18 -0
  28. data/app/assets/templates/caboose_store/product/images.jst.ejs +8 -0
  29. data/app/assets/templates/caboose_store/product/options.jst.ejs +19 -0
  30. data/app/controllers/caboose_store/application_controller.rb +1 -11
  31. data/app/controllers/caboose_store/cart_controller.rb +36 -44
  32. data/app/controllers/caboose_store/cart_controller.rb.bak +169 -0
  33. data/app/controllers/caboose_store/categories_controller.rb +72 -92
  34. data/app/controllers/caboose_store/checkout_controller.rb +231 -151
  35. data/app/controllers/caboose_store/orders_controller.rb +235 -95
  36. data/app/controllers/caboose_store/product_images_controller.rb +1 -1
  37. data/app/controllers/caboose_store/products_controller.rb +275 -84
  38. data/app/controllers/caboose_store/reviews_controller.rb +1 -1
  39. data/app/controllers/caboose_store/variants_controller.rb +86 -20
  40. data/app/controllers/caboose_store/vendors_controller.rb +73 -0
  41. data/app/helpers/caboose_store/application_helper.rb +3 -41
  42. data/app/helpers/caboose_store/cart_helper.rb +0 -24
  43. data/app/helpers/caboose_store/categories_helper.rb +69 -25
  44. data/app/helpers/caboose_store/checkout_helper.rb +31 -0
  45. data/app/helpers/caboose_store/products_helper.rb +4 -80
  46. data/app/mailers/caboose_store/orders_mailer.rb +6 -13
  47. data/app/models/caboose_store/address.rb +5 -9
  48. data/app/models/caboose_store/caboose_store_plugin.rb +18 -7
  49. data/app/models/caboose_store/category.rb +66 -41
  50. data/app/models/caboose_store/category_membership.rb +1 -2
  51. data/app/models/caboose_store/customization_membership.rb +10 -0
  52. data/app/models/caboose_store/discount.rb +4 -2
  53. data/app/models/caboose_store/line_item.rb +77 -0
  54. data/app/models/caboose_store/message.rb +3 -5
  55. data/app/models/caboose_store/order.rb +153 -63
  56. data/app/models/caboose_store/order_discount.rb +1 -2
  57. data/app/models/caboose_store/order_pdf.rb +2 -4
  58. data/app/models/caboose_store/payment_processors/authorizenet.rb +20 -2
  59. data/app/models/caboose_store/payment_processors/base.rb +0 -2
  60. data/app/models/caboose_store/payment_processors/payscape.rb +91 -1
  61. data/app/models/caboose_store/product.rb +86 -30
  62. data/app/models/caboose_store/product_image.rb +50 -15
  63. data/app/models/caboose_store/product_image_variant.rb +3 -3
  64. data/app/models/caboose_store/review.rb +8 -8
  65. data/app/models/caboose_store/schema.rb +174 -119
  66. data/app/models/caboose_store/search_filter.rb +110 -115
  67. data/app/models/caboose_store/shipping_calculator.rb +51 -49
  68. data/app/models/caboose_store/tax_calculator.rb +2 -6
  69. data/app/models/caboose_store/tax_line.rb +1 -4
  70. data/app/models/caboose_store/variant.rb +77 -21
  71. data/app/models/caboose_store/vendor.rb +17 -2
  72. data/app/views/caboose_store/cart/index.html.erb +3 -18
  73. data/app/views/caboose_store/categories/admin_edit.html.erb +64 -67
  74. data/app/views/caboose_store/categories/admin_index.html.erb +7 -9
  75. data/app/views/caboose_store/categories/admin_new.html.erb +56 -39
  76. data/app/views/caboose_store/checkout/_address_form.html.erb +111 -0
  77. data/app/views/caboose_store/checkout/_billing_form.html.erb +47 -0
  78. data/app/views/caboose_store/checkout/_cart.html.erb +52 -0
  79. data/app/views/caboose_store/checkout/_order_discount.html.erb +40 -0
  80. data/app/views/caboose_store/checkout/_shipping_address.html.erb +10 -0
  81. data/app/views/caboose_store/checkout/_shipping_method.html.erb +2 -0
  82. data/app/views/caboose_store/checkout/_shipping_method_form.html.erb +21 -0
  83. data/app/views/caboose_store/checkout/billing.html.erb +4 -161
  84. data/app/views/caboose_store/checkout/discount.html.erb +5 -160
  85. data/app/views/caboose_store/checkout/empty.html.erb +2 -0
  86. data/app/views/caboose_store/checkout/error.html.erb +2 -0
  87. data/app/views/caboose_store/checkout/index.html.erb +30 -100
  88. data/app/views/caboose_store/checkout/login.html.erb +2 -0
  89. data/app/views/caboose_store/checkout/payment.html.erb +79 -0
  90. data/app/views/caboose_store/checkout/relay.html.erb +12 -0
  91. data/app/views/caboose_store/checkout/relay_postMessage.html.erb +19 -0
  92. data/app/views/caboose_store/checkout/shipping.html.erb +8 -83
  93. data/app/views/caboose_store/checkout/step_one.html.erb +15 -0
  94. data/app/views/caboose_store/checkout/step_two.html.erb +15 -0
  95. data/app/views/caboose_store/checkout/thanks.html.erb +5 -0
  96. data/app/views/caboose_store/layouts/_footer.html.erb +1 -1
  97. data/app/views/caboose_store/orders/admin_edit.html.erb +101 -7
  98. data/app/views/caboose_store/orders/admin_index.html.erb +8 -8
  99. data/app/views/caboose_store/orders_mailer/customer_new_order.html.erb +0 -46
  100. data/app/views/caboose_store/orders_mailer/customer_status_updated.html.erb +0 -48
  101. data/app/views/caboose_store/orders_mailer/fulfillment_new_order.html.erb +0 -42
  102. data/app/views/caboose_store/orders_mailer/shipping_order_ready.html.erb +0 -45
  103. data/app/views/caboose_store/products/_admin_header.html.erb +7 -6
  104. data/app/views/caboose_store/products/_sort_options.html.erb +19 -0
  105. data/app/views/caboose_store/products/admin_add_upcs.html.erb +58 -0
  106. data/app/views/caboose_store/products/admin_edit_categories.html.erb +1 -1
  107. data/app/views/caboose_store/products/admin_edit_description.html.erb +2 -5
  108. data/app/views/caboose_store/products/admin_edit_general.html.erb +58 -1
  109. data/app/views/caboose_store/products/admin_edit_images.html.erb +3 -1
  110. data/app/views/caboose_store/products/admin_edit_variants.html.erb +13 -2
  111. data/app/views/caboose_store/products/admin_edit_variants_single.html.erb +14 -14
  112. data/app/views/caboose_store/products/admin_group_variants.html.erb +433 -0
  113. data/app/views/caboose_store/products/admin_index.html.erb +87 -39
  114. data/app/views/caboose_store/products/admin_sort.html copy.erb +155 -0
  115. data/app/views/caboose_store/products/admin_sort.html.erb +254 -0
  116. data/app/views/caboose_store/products/details.html.erb +1 -2
  117. data/app/views/caboose_store/variants/admin_edit.html.erb +18 -16
  118. data/app/views/caboose_store/variants/admin_group.html.erb +184 -0
  119. data/app/views/caboose_store/vendors/admin_edit.html.erb +24 -0
  120. data/app/views/caboose_store/vendors/admin_index.html.erb +30 -0
  121. data/app/views/caboose_store/vendors/admin_new.html.erb +34 -0
  122. data/config/routes.rb +65 -27
  123. data/lib/caboose-store/caboose_store_helper.rb +29 -30
  124. data/lib/caboose-store/engine.rb +73 -28
  125. data/lib/caboose-store/version.rb +1 -1
  126. data/lib/caboose-store.rb +16 -7
  127. data/lib/tasks/caboose-store.rake +0 -2
  128. metadata +54 -17
  129. data/app/assets/javascripts/caboose_store/modal.js +0 -52
  130. data/app/assets/javascripts/caboose_store/modal_integration.js +0 -25
  131. data/app/assets/javascripts/caboose_store/model.form.page.js +0 -30
  132. data/app/assets/javascripts/caboose_store/model.form.user.js +0 -36
  133. data/app/assets/javascripts/caboose_store/payment_processors/authorizenet.js +0 -21
  134. data/app/assets/javascripts/caboose_store/payment_processors/base.js +0 -21
  135. data/app/assets/javascripts/caboose_store/payment_processors/payscape.js +0 -21
  136. data/app/assets/javascripts/caboose_store/shortcut.js +0 -11
  137. data/app/assets/javascripts/caboose_store/station.js +0 -60
  138. data/app/models/caboose_store/order_line_item.rb +0 -13
  139. data/app/models/caboose_store/states.rb +0 -60
  140. data/app/views/caboose_store/application/_category_thumb.html.erb +0 -6
  141. data/app/views/caboose_store/application/_product_thumb.html.erb +0 -13
  142. data/app/views/caboose_store/checkout/quantity_box.html.erb +0 -39
  143. data/app/views/caboose_store/checkout/thank_you.html.erb +0 -36
@@ -1,82 +1,79 @@
1
- <%
2
- cat = @category
3
- %>
4
1
  <h1>Edit Category</h1>
5
2
 
6
- <p><div id='category_<%= cat.id %>_name' ></div></p>
7
- <p><div id='category_<%= cat.id %>_slug' ></div></p>
8
- <p><div id='category_<%= cat.id %>_square_offset_x' ></div></p>
9
- <p><div id='category_<%= cat.id %>_square_offset_y' ></div></p>
10
- <p><div id='category_<%= cat.id %>_square_scale_factor' ></div></p>
11
- <p><div id='category_<%= cat.id %>_image' ></div></p>
3
+ <p><div class="push-below" id="category_<%= @category.id %>_name"></div></p>
4
+ <p><div class="push-below" id="category_<%= @category.id %>_slug"></div></p>
5
+ <p><div class="push-below" id="category_<%= @category.id %>_status"></div></p>
6
+ <p><div class="push-below" id="category_<%= @category.id %>_image"></div></p>
12
7
 
13
8
  <h2>Products</h2>
14
- <% if cat.products && cat.products.count > 0 %>
9
+
10
+ <% if @category.products.any? %>
15
11
  <ul>
16
- <% cat.products.each do |p| %>
17
- <li><a href='/admin/products/<%= p.id %>/general'><%= p.title %></a></li>
12
+ <% @category.products.each do |product| %>
13
+ <li><a href="/admin/products/<%= product.id %>/general"><%= product.title %></a></li>
18
14
  <% end %>
19
15
  </ul>
20
16
  <% else %>
21
- <p>This category has no products.</p>
17
+ <p>This category has no associated products.</p>
22
18
  <% end %>
23
19
 
24
- <div id='message'></div>
25
- <p>
26
- <input type='button' value='< Back' onclick="window.location='/admin/categories';" />
27
- <input type='button' value='Delete Category' onclick="delete_category(<%= cat.id %>);" />
28
- </p>
20
+ <div id="message"></div>
21
+ <input type="button" value="< Back" onclick="window.location='/admin/categories'" />
22
+ <input type="button" value="Delete Category" onclick="delete_category(<%= @category.id %>)" />
29
23
 
24
+ <% content_for :caboose_css do %>
25
+ <style>
26
+ .push-below { margin-bottom: 24px; }
27
+ </style>
28
+ <% end %>
30
29
 
31
30
  <% content_for :caboose_js do %>
32
- <%= javascript_include_tag "caboose/model/all" %>
33
- <script type='text/javascript'>
34
-
35
- var modal = false;
36
- $(window).load(function() {
37
- modal = new CabooseModal(800);
38
- });
39
-
40
- $(document).ready(function() {
41
- m = new ModelBinder({
42
- name: 'Category',
43
- id: <%= cat.id %>,
44
- update_url: '/admin/categories/<%= cat.id %>',
45
- authenticity_token: '<%= form_authenticity_token %>',
46
- attributes: [
47
- { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(cat.name ) %>, width: 400 },
48
- { name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(cat.slug ) %>, width: 400 },
49
- { name: 'square_offset_x' , nice_name: 'Offset X' , type: 'text' , value: <%= raw Caboose.json(cat.square_offset_x ) %>, width: 200 },
50
- { name: 'square_offset_y' , nice_name: 'Offset Y' , type: 'text' , value: <%= raw Caboose.json(cat.square_offset_y ) %>, width: 200 },
51
- { name: 'square_scale_factor' , nice_name: 'Scale Factor' , type: 'text' , value: <%= raw Caboose.json(cat.square_scale_factor ) %>, width: 200 },
52
- { name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(cat.image.url(:medium) ) %>, width: 200 }
53
- ]
54
- });
55
- });
56
-
57
- function delete_category(cat_id, confirm)
58
- {
59
- if (!confirm)
60
- {
61
- var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
62
- .append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
63
- .append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
64
- .append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
65
- modal.autosize(p, 'message');
66
- return;
67
- }
68
- modal.autosize("<p class='loading'>Deleting the category...</p>");
69
- $.ajax({
70
- url: '/admin/categories/' + cat_id,
71
- type: 'delete',
72
- success: function(resp) {
73
- if (resp.error)
74
- modal.autosize("<p class='note error'>" + resp.error + "</p>");
75
- if (resp.redirect)
76
- window.location = resp.redirect
31
+ <%= javascript_include_tag "caboose/model/all" %>
32
+
33
+ <script type='text/javascript'>
34
+ var modal = false;
35
+
36
+ $(window).load(function() {
37
+ modal = new CabooseModal(800);
38
+ });
39
+
40
+ $(document).ready(function() {
41
+ m = new ModelBinder({
42
+ name: 'Category',
43
+ id: <%= @category.id %>,
44
+ update_url: '/admin/categories/<%= @category.id %>',
45
+ authenticity_token: '<%= form_authenticity_token %>',
46
+ attributes: [
47
+ { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(@category.name) %> , width: 400 },
48
+ { name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@category.slug) %> , width: 400 },
49
+ { name: 'status', nice_name: 'Status', type: 'select', value: <%= raw Caboose.json(@category.status) %> , width: 400 , text: <%= raw Caboose.json(@category.status) %>, options_url: '/admin/categories/status-options' },
50
+ { name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@category.image.url(:medium)) %> , width: 200 }
51
+ ]
52
+ });
53
+ });
54
+
55
+ function delete_category(cat_id, confirm) {
56
+ if (!confirm) {
57
+ var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
58
+ .append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
59
+ .append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
60
+ .append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
61
+
62
+ modal.autosize(p, 'message');
63
+
64
+ return;
65
+ }
66
+
67
+ modal.autosize("<p class='loading'>Deleting the category...</p>");
68
+
69
+ $.ajax({
70
+ url: '/admin/categories/' + cat_id,
71
+ type: 'delete',
72
+ success: function(resp) {
73
+ if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
74
+ if (resp.redirect) window.location = resp.redirect;
75
+ }
76
+ });
77
77
  }
78
- });
79
- }
80
-
81
- </script>
78
+ </script>
82
79
  <% end %>
@@ -1,13 +1,11 @@
1
1
  <h1>Categories</h1>
2
-
3
- <div id='new_button'><a href='/admin/categories/new'><span>New Category</span></a></div>
4
-
5
- <%= raw categories_tree(@top_category) %>
2
+ <a href='/admin/categories/new'>New Category</a>
3
+ <%= category_list %>
6
4
 
7
5
  <% content_for :caboose_js do %>
8
- <script type='text/javascript'>
9
- $(document).ready(function() {
10
- var modal = new CabooseModal(800);
11
- });
12
- </script>
6
+ <script type='text/javascript'>
7
+ $(document).ready(function() {
8
+ var modal = new CabooseModal(800);
9
+ });
10
+ </script>
13
11
  <% end %>
@@ -1,45 +1,62 @@
1
- <%
2
- p = @product
3
- %>
4
1
  <h1>New Category</h1>
5
2
 
6
- <form action='/admin/categories' method='post' id='new_form'>
7
- <select name='parent_id'>
8
- <option value=''>-- Parent Category --</option>
9
- <%= raw categories_options(@top_category) %>
10
- </select>
11
- <input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>" />
12
- <p><input type='text' name='name' value='' placeholder='Category Name' style='width: 400px;' /></p>
13
- <div id='message'></div>
14
- <p>
15
- <input type='button' value='< Back' onclick="window.location='/admin/categories';" />
16
- <input type='submit' value='Add Category' onclick='add_category(); return false' />
17
- </p>
3
+ <form action="/admin/categories" method="post" id="new_form">
4
+ <!-- <select name="parent_id">
5
+ <option value="">-- Parent Category --</option>
6
+ <%=
7
+ #raw categories_options(@root_category)
8
+ %>
9
+ </select> -->
10
+
11
+ <%= category_select('parent_id') %>
12
+
13
+ <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
14
+ <input type="text" name="name" placeholder="Category Name" />
15
+
16
+ <div id="message"></div>
17
+
18
+ <input type="button" value="< Back" onclick="window.location='/admin/categories';" />
19
+ <input type="submit" value="Add Category" onclick="add_category(); return false" />
18
20
  </form>
19
21
 
20
- <% content_for :caboose_js do %>
21
- <%= javascript_include_tag "caboose/model/all" %>
22
- <script type='text/javascript'>
23
-
24
- function add_category()
25
- {
26
- modal.autosize("<p class='loading'>Adding category...</p>");
27
- $.ajax({
28
- url: '/admin/categories',
29
- type: 'post',
30
- data: $('#new_form').serialize(),
31
- success: function(resp) {
32
- if (resp.error)
33
- modal.autosize("<p class='note error'>" + resp.error + "</p>");
34
- if (resp.redirect)
35
- window.location = resp.redirect
36
- }
37
- });
38
- }
22
+ <% content_for :caboose_css do %>
23
+ <style>
24
+ form { width: 400px; }
25
+ form input[type=text], select { width: 100%; }
26
+ form input[type=text] {
27
+ box-sizing: border-box;
28
+ margin: 12px 0;
29
+ height: 42px;
30
+ line-height: 42px;
31
+ }
32
+ select,
33
+ form input[type=button],
34
+ form input[type=submit] { cursor: pointer; }
35
+ </style>
36
+ <% end %>
39
37
 
40
- var modal = false;
41
- $(window).load(function() {
42
- modal = new CabooseModal(800);
43
- });
44
- </script>
38
+ <% content_for :caboose_js do %>
39
+ <%= javascript_include_tag "caboose/model/all" %>
40
+
41
+ <script type='text/javascript'>
42
+ function add_category() {
43
+ modal.autosize("<p class='loading'>Adding category...</p>");
44
+
45
+ $.ajax({
46
+ url: '/admin/categories',
47
+ type: 'post',
48
+ data: $('#new_form').serialize(),
49
+ success: function(resp) {
50
+ if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
51
+ if (resp.redirect) window.location = resp.redirect
52
+ }
53
+ });
54
+ }
55
+
56
+ var modal = false;
57
+
58
+ $(window).load(function() {
59
+ modal = new CabooseModal(800);
60
+ });
61
+ </script>
45
62
  <% end %>
@@ -0,0 +1,111 @@
1
+ <% if logged_in? %>
2
+ <form action="/checkout/shipping" method="post" id="address">
3
+ <section>
4
+ <fieldset id="shipping">
5
+ <h3>Shipping Address</h3>
6
+
7
+ <table>
8
+ <div>
9
+ <label for="shipping-first-name">First Name:</label>
10
+ <input id="shipping-first-name" name="shipping[first_name]" type="text" value="<%= @order.shipping_address.first_name if @order.shipping_address %>" />
11
+ </div>
12
+
13
+ <div>
14
+ <label for="shipping-last-name">Last Name:</label>
15
+ <input id="shipping-last-name" name="shipping[last_name]" type="text" value="<%= @order.shipping_address.last_name if @order.shipping_address %>" />
16
+ </div>
17
+
18
+ <div>
19
+ <label for="shipping-company">Company:</label>
20
+ <input id="shipping-company" name="shipping[company]" type="text" value="<%= @order.shipping_address.company if @order.shipping_address and @order.shipping_address.company %>" />
21
+ </div>
22
+
23
+ <div>
24
+ <label for="shipping-address1">Address 1:</label>
25
+ <input id="shipping-address1" name="shipping[address1]" type="text" value="<%= @order.shipping_address.address1 if @order.shipping_address %>" />
26
+ </div>
27
+
28
+ <div>
29
+ <label for="shipping-address2">Address 2:</label>
30
+ <input id="shipping-address2" name="shipping[address2]" type="text" value="<%= @order.shipping_address.address2 if @order.shipping_address %>" />
31
+ </div>
32
+
33
+ <div>
34
+ <label for="shipping-city">City:</label>
35
+ <input id="shipping-city" name="shipping[city]" type="text" value="<%= @order.shipping_address.city if @order.shipping_address %>" />
36
+ </div>
37
+
38
+ <div>
39
+ <label for="shipping-state">State:</label>
40
+ <select id="shipping-state" name="shipping[state]">
41
+ <% Caboose::States.all.each do |abbr, name| %>
42
+ <option value="<%= abbr %>"><%= name %></option>
43
+ <% end %>
44
+ </select>
45
+ </div>
46
+
47
+ <div>
48
+ <label for="shipping-zip">Zip:</label>
49
+ <input id="shipping-zip" name="shipping[zip]" type="text" value="<%= @order.shipping_address.zip if @order.shipping_address %>" />
50
+ </div>
51
+
52
+ <label>Use as billing:</label>
53
+ <input id="use-as-billing" name="shipping[use_as_billing]" type="checkbox" checked />
54
+ </table>
55
+ </fieldset>
56
+
57
+ <fieldset id="billing">
58
+ <h3>Billing Address</h3>
59
+
60
+ <table>
61
+ <div>
62
+ <label for="billing-first-name">First Name:</label>
63
+ <input id="billing-first-name" name="billing[first_name]" type="text" value="<%= @order.billing_address.first_name if @order.billing_address %>" />
64
+ </div>
65
+
66
+ <div>
67
+ <label for="billing-last-name">Last Name:</label>
68
+ <input id="billing-last-name" name="billing[last_name]" type="text" value="<%= @order.billing_address.last_name if @order.billing_address %>" />
69
+ </div>
70
+
71
+ <div>
72
+ <label for="billing-company">Company:</label>
73
+ <input id="billing-company" name="billing[company]" type="text" value="<%= @order.billing_address.company if @order.billing_address and @order.billing_address.company %>" />
74
+ </div>
75
+
76
+ <div>
77
+ <label for="billing-address1">Address 1:</label>
78
+ <input id="billing-address1" name="billing[address1]" type="text" value="<%= @order.billing_address.address1 if @order.billing_address %>" />
79
+ </div>
80
+
81
+ <div>
82
+ <label for="billing-address2">Address 2:</label>
83
+ <input id="billing-address2" name="billing[address2]" type="text" value="<%= @order.billing_address.address2 if @order.billing_address %>" />
84
+ </div>
85
+
86
+ <div>
87
+ <label for="billing-city">City:</label>
88
+ <input id="billing-city" name="billing[city]" type="text" value="<%= @order.billing_address.city if @order.billing_address %>" />
89
+ </div>
90
+
91
+ <div>
92
+ <label for="">State:</label>
93
+ <select name="billing[state]">
94
+ <% Caboose::States.all.each do |abbr, name| %>
95
+ <option value="<%= abbr %>"><%= name %></option>
96
+ <% end %>
97
+ </select>
98
+ </div>
99
+
100
+ <div>
101
+ <label for="">Zip:</label>
102
+ <input id="billing-zip" name="billing[zip]" type="text" value="<%= @order.billing_address.zip if @order.billing_address %>" />
103
+ </div>
104
+ </table>
105
+ </fieldset>
106
+ </section>
107
+
108
+ <div id="message"></div>
109
+ <input type="submit" value="Continue >" />
110
+ </form>
111
+ <% end %>
@@ -0,0 +1,47 @@
1
+ <% if @order.discounts.any? && @order.total < @order.discounts.first.amount_current %>
2
+ <p style="margin: 24px 0 0">Gift Card covers purchase.</p>
3
+ <button onclick="window.location='/checkout/discount'" style="margin: 12px 0 0">&lt; Back</button>
4
+ <button onclick="window.location='/checkout/authorize-by-gift-card'" style="margin: 12px 0 0">Continue &gt;</button>
5
+ <% else %>
6
+ <input id="billing-amount" type="hidden" value="<%= @order.total %>" />
7
+
8
+ <form id="billing-form" action="<%= @form_url %>" method="post" target="payment-request">
9
+ <input name="billing-cc-exp" type="hidden" value="01<%= DateTime.now.year.to_s[2..4] %>" />
10
+
11
+ <div>
12
+ <label for="billing-number">Card number:</label>
13
+ <input id="billing-number" type="text" name="billing-cc-number" maxlength="16" />
14
+ </div>
15
+
16
+ <div>
17
+ <label for="billing-expiration-month">Expiration:</label>
18
+ <select id="billing-expiration-month">
19
+ <option value="01">01 - Jan</option>
20
+ <option value="02">02 - Feb</option>
21
+ <option value="03">03 - Mar</option>
22
+ <option value="04">04 - Apr</option>
23
+ <option value="05">05 - May</option>
24
+ <option value="06">06 - Jun</option>
25
+ <option value="07">07 - Jul</option>
26
+ <option value="08">08 - Aug</option>
27
+ <option value="09">09 - Sep</option>
28
+ <option value="10">10 - Oct</option>
29
+ <option value="11">11 - Nov</option>
30
+ <option value="12">12 - Dec</option>
31
+ </select>
32
+ /
33
+ <select id="billing-expiration-year" name="exp_year">
34
+ <% (DateTime.now.year...DateTime.now.year + 20).each do |i| %>
35
+ <option value="<%= i-2000 %>"><%= i %></option>
36
+ <% end %>
37
+ </select>
38
+ </div>
39
+
40
+ <input type="button" value="< Back" onclick="window.location='/checkout/discount';" />
41
+ <input type="submit" value="Continue >" />
42
+ </form>
43
+
44
+ <p><a href="/checkout/discount"><%= if @order.discounts.any? then 'Update Gift Card' else 'Add Gift Card' end %></a></p>
45
+
46
+ <iframe style="display: none" id="payment-request" name="payment-request"></iframe>
47
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <table id="cart">
2
+ <tr>
3
+ <th>Item</th>
4
+ <th>Quantity</th>
5
+ <th>Subtotal</th>
6
+ </tr>
7
+
8
+ <% @order.line_items.each do |line_item| %>
9
+ <tr>
10
+ <td>
11
+ <%= line_item.variant.product.title %> - <%= line_item.variant.title %>
12
+
13
+ <% line_item.customizations.each do |customization| %>
14
+ <p><%= "- #{customization.variant.product.custom_input}: #{customization.custom_input}"%></p>
15
+ <% end %>
16
+ </td>
17
+ <td align="right"><%= line_item.quantity %></td>
18
+ <td align="right"><%= number_to_currency(line_item.subtotal) %></td>
19
+ </tr>
20
+ <% end %>
21
+
22
+ <tr>
23
+ <td colspan="2" align="right">Subtotal</td>
24
+ <td align="right"><%= number_to_currency(@order.subtotal) %></td>
25
+ </tr>
26
+
27
+ <% if @order.tax and @order.tax > 0 %>
28
+ <tr>
29
+ <td colspan="2" align="right">Tax <span class="float: right">+</span></td>
30
+ <td align="right"><%= number_to_currency(@order.tax) %></td>
31
+ </tr>
32
+ <% end %>
33
+
34
+ <% if @order.shipping and @order.handling %>
35
+ <tr>
36
+ <td colspan="2" align="right">Shipping &amp; Handling <span class="float: right">+</span></td>
37
+ <td align="right"><%= number_to_currency(@order.shipping + @order.handling) %></td>
38
+ </tr>
39
+ <% end %>
40
+
41
+ <% if @order.discounts.any? %>
42
+ <tr>
43
+ <td colspan="2" align="right">Gift Card <span class="float: right">-</span></td>
44
+ <td align="right"><%= number_to_currency(@order.discounts.first.amount_current) %></td>
45
+ </tr>
46
+ <% end %>
47
+
48
+ <tr>
49
+ <td colspan="2" align="right">Total <span class="float: right">=</span></td>
50
+ <td align="right"><%= number_to_currency(@order.total) %></td>
51
+ </tr>
52
+ </table>
@@ -0,0 +1,40 @@
1
+ <form id="discounts">
2
+ <label for="gift-card" style="margin: 0 0 12px">Gift Card Number:</label>
3
+ <input id="gift-card" name="gift_card_number" type="text" placeholder="<%= @order.discounts.first.code if @order.discounts.any? %>" maxlength="8" />
4
+ <div id="message"></div>
5
+
6
+ <input id="back" type="button" value="< Back" onclick="window.location='/checkout/shipping'" />
7
+ <input id="next" type="submit" value="<%= if @order.discounts.any? then 'Update' else 'Add' end %>" />
8
+ <input id="skip" type="button" value="<%= if @order.discounts.any? then 'Continue >' else 'Skip >' end %>" onclick="window.location='/checkout/billing'" />
9
+ </form>
10
+
11
+ <% content_for :caboose_js do %>
12
+ <script>
13
+ $(document).ready(function() {
14
+ var $form = $('#discounts');
15
+
16
+ $form.on('submit', function(event) {
17
+ event.preventDefault();
18
+
19
+ $.ajax({
20
+ url: '/checkout/discount',
21
+ type: 'post',
22
+ data: $form.serialize(),
23
+ success: function(response) {
24
+ console.log(response);
25
+
26
+ if (response.success) {
27
+ $('#next').empty().val('Update')
28
+ $('#skip').empty().val('Continue >');
29
+ $('#message').removeClass('error').addClass('success');
30
+ } else {
31
+ $('#message').removeClass('success').addClass('error');
32
+ }
33
+
34
+ $('#message').empty().text(response.message);
35
+ }
36
+ });
37
+ });
38
+ });
39
+ </script>
40
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% @shipping_address ||= @order.shipping_address %>
2
+
3
+ <address>
4
+ <%= "#{@shipping_address.first_name} #{@shipping_address.last_name}" %><br />
5
+ <%= @shipping_address.address1 %><br />
6
+ <%= "#{@shipping_address.address2}" if @shipping_address.address2 and not @shipping_address.address2.empty? %><br />
7
+ <%= "#{@shipping_address.city}, #{@shipping_address.state} #{@shipping_address.zip}" %>
8
+ </address>
9
+
10
+ <p><a href="/checkout">Edit shipping address</a></p>
@@ -0,0 +1,2 @@
1
+ <div><%= @order.shipping_method %> - <%= number_to_currency(@order.shipping) %></div>
2
+ <p><a href="/checkout/shipping">Edit shipping method</a></p>
@@ -0,0 +1,21 @@
1
+ <form id="shipping-rates" action="" method="put">
2
+ <fieldset>
3
+ <% @shipping_rates.each do |rate| %>
4
+ <div>
5
+ <input id="shipping-method-<%= rate['service_code'] %>" name="shipping_method_code" type="radio" value="<%= rate['service_code'] %>" />
6
+ <input id="shipping-method-<%= rate['service_code'] %>-name" type="hidden" value="<%= rate['service_name'] %>" />
7
+ <input id="shipping-method-<%= rate['service_code'] %>-price" type="hidden" value="<%= if rate['negotiated_rate'] and rate['negotiated_rate'] > 0 then rate['negotiated_rate'] else rate['total_price'] end %>" />
8
+
9
+ <label for="shipping-method-<%= rate['service_code'] %>">
10
+ <%= number_to_currency rate['total_price'].to_s.insert(-3, '.') %>
11
+ <%= rate['service_name'] %>
12
+ </label>
13
+ </div>
14
+ <% end %>
15
+ </fieldset>
16
+
17
+ <div id="message"></div>
18
+
19
+ <input type="button" value="< Back" onclick="window.location='/checkout';" />
20
+ <input type="submit" value="Continue >" />
21
+ </form>