caboose-cms 0.5.158 → 0.5.159

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2YwM2I5ZDUwYzdhZTQyZGRjZTFjMmI1MjFlNGRmYTk1ZDkxZjAwYw==
4
+ NGRlMTBkOTUzOWM0NzkxZGQ0NGVlMDdlY2E3MzQ3ZDMxYjAzZjg5Mg==
5
5
  data.tar.gz: !binary |-
6
- MDE0NWMxY2IzNjZiZTJiODliMDY5NTlhZTU1NDlkMzY3Mjk1OGMyZQ==
6
+ MGQxNDcyYWIzNzBlOGJhZjNmYzY4OGNhZjRmMDQ4YTc2MzA1MDc3ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWU2N2NjYjE0MWVjNzY1Y2Y2YjQyNWZmMTNhZmE3Y2NmMTdmOTJkMDlkMzdj
10
- MjNjY2M1M2FkNzBjMjAzMTNmZWIyYjkyOTc1MTZlZGRiNjEwNmQyMzQ3OWE1
11
- YzE1ZmFjNTcyMzA4MGVmYTQ1MWY1YTM3MzA5NTRhNDhiOTRlYmE=
9
+ ZjEzN2NlM2M3YzEwMzA2MDBiMWUzYTczMjFmZWFiOTIyYTQ3NWY2ZTM2YjY1
10
+ ZWFhOWMwNWMxYTJlNmU5MzBmZWEwNzAzNWFjZDZiOTk3ZDE1ZTdjMWVlOWMz
11
+ NTE5Y2RjZDk1NjM0YTNlNTAyZTAzYTQ2ODQxMWI3MDgxMzk5OTg=
12
12
  data.tar.gz: !binary |-
13
- NGI0ODI2ZWVjYWMyNzM1MWNhNjM5YmQwMzQyNjFjOTA5ZjAzNzJjM2EwYzIx
14
- YzA3YTg3YmE0MTJhYmRlYjAyZTFlMGRhMzk1NTlmMWQyMjdjM2I5MWU0NTQ3
15
- MGQyYTBmOWYyOWI3YTI4Yzk0ZjE2NmZiOTdmYjY4MzM0NjcyNTM=
13
+ ZjkwYmVjNjE3MDU4ZGEzYmRiNmVhYmE2MTM5NjI4NjViYzRlMGVjZjI2Mzgz
14
+ ZDE3YTFlM2Y5N2E4OTA0OTg3NThlOGQyMzYzMWJjNDAyMzU2NmU4MGFjYmI1
15
+ NTliODNmZmFmMWQyMDE5MGNmYWZmMzAyODEyYzk2NDE1MzZhNDc=
@@ -0,0 +1,2 @@
1
+
2
+ #my_account p { margin-bottom: 10px; }
@@ -325,7 +325,7 @@ module Caboose
325
325
  OrdersMailer.configure_for_site(@site.id).fulfillment_new_order(order).deliver
326
326
 
327
327
  # Emit order event
328
- Caboose.plugin_hook('order_authorized', order)
328
+ Caboose.plugin_hook('order_authorized', order)
329
329
  else
330
330
  order.financial_status = 'unauthorized'
331
331
  error = "There was a problem processing your payment."
@@ -348,6 +348,16 @@ module Caboose
348
348
  @resp.success = true if params[:success]
349
349
  @resp.error = params[:error] if params[:error]
350
350
 
351
+ # Go ahead and capture funds if the order only contained downloadable items
352
+ @order = Order.find(params[:order_id])
353
+ if !@order.has_shippable_items?
354
+ capture_resp = @order.capture_funds
355
+ if capture_resp.error
356
+ @resp.success = false
357
+ @resp.error = capture_resp.error
358
+ end
359
+ end
360
+
351
361
  if @resp.success
352
362
  session[:cart_id] = nil
353
363
  init_cart
@@ -235,6 +235,64 @@ module Caboose
235
235
  return false
236
236
  end
237
237
 
238
+ def capture_funds
239
+
240
+ resp = StdClass.new
241
+ t = OrderTransaction.where(:order_id => self.id, :transaction_type => OrderTransaction::TYPE_AUTHORIZE, :success => true).first
242
+
243
+ if self.financial_status == Order::FINANCIAL_STATUS_CAPTURED
244
+ resp.error = "Funds for this order have already been captured."
245
+ elsif order.total > t.amount
246
+ resp.error = "The order total exceeds the authorized amount."
247
+ elsif t.nil?
248
+ resp.error = "This order doesn't seem to be authorized."
249
+ else
250
+
251
+ sc = self.site.store_config
252
+ case sc.pp_name
253
+ when 'authorize.net'
254
+ transaction = AuthorizeNet::AIM::Transaction.new(sc.pp_username, sc.pp_password)
255
+ response = transaction.prior_auth_capture(t.transaction_id, self.total)
256
+
257
+ self.update_attribute(:financial_status, Order::FINANCIAL_STATUS_CAPTURED)
258
+ resp.success = 'Captured funds successfully'
259
+
260
+ ot = Caboose::OrderTransaction.new(
261
+ :order_id => self.id,
262
+ :date_processed => DateTime.now.utc,
263
+ :transaction_type => OrderTransaction::TYPE_CAPTURE
264
+ )
265
+ ot.success = response.response_code && response.response_code == '1'
266
+ ot.transaction_id = response.transaction_id
267
+ ot.auth_code = response.authorization_code
268
+ ot.response_code = response.response_code
269
+ ot.amount = self.total
270
+ ot.save
271
+
272
+ when 'payscape'
273
+ # TODO: Implement capture funds for payscape
274
+
275
+ end
276
+
277
+ #if (order.discounts.any? && order.total < order.discounts.first.amount_current) || PaymentProcessor.capture(order)
278
+ # order.financial_status = 'captured'
279
+ # order.save
280
+ #
281
+ # if order.discounts.any?
282
+ # order.update_attribute(:amount_discounted, order.discounts.first.amount_current)
283
+ # order.update_gift_cards
284
+ # end
285
+ #
286
+ # response.success = "Captured funds successfully"
287
+ #else
288
+ # response.error = "Error capturing funds."
289
+ #end
290
+
291
+ end
292
+
293
+ return resp
294
+ end
295
+
238
296
  end
239
297
  end
240
298
 
@@ -55,6 +55,7 @@ module Caboose
55
55
  # Make sure all the items in the order have attributes set
56
56
  order.line_items.each do |li|
57
57
  v = li.variant
58
+ next if v.downloadable
58
59
  Caboose.log("Error: variant #{v.id} has a zero weight") and return false if v.weight.nil? || v.weight == 0
59
60
  next if v.volume && v.volume > 0
60
61
  Caboose.log("Error: variant #{v.id} has a zero length") and return false if v.length.nil? || v.length == 0
@@ -64,19 +65,14 @@ module Caboose
64
65
  v.save
65
66
  end
66
67
 
67
- # Reorder the items in the order by volume
68
- h = {}
69
- order.line_items.each do |li|
70
- (1..li.quantity).each do |i|
71
- v = li.variant
72
- h[v.volume] = li
73
- end
74
- end
75
- line_items = h.sort_by{ |k,v| k }.collect{ |x| x[1] }
68
+ # Reorder the items in the order by volume
69
+ line_items = order.line_items.sort_by{ |li| li.quantity * (li.variant.volume ? li.variant.volume : 0.00) * -1 }
70
+
71
+ # Get all the packages we're going to use
76
72
  all_packages = ShippingPackage.where(:site_id => order.site_id).reorder(:flat_rate_price).all
77
73
 
78
- # Now go through each variant and fit it in a new or existing package
79
- line_items.each do |li|
74
+ # Now go through each variant and fit it in a new or existing package
75
+ line_items.each do |li|
80
76
  next if li.variant.downloadable
81
77
 
82
78
  # See if the item will fit in any of the existing packages
@@ -1,17 +1,17 @@
1
1
 
2
- <h1>My Account</h1>
3
-
4
- <p><div id='user_<%= @user.id %>_first_name' ></div></p>
5
- <p><div id='user_<%= @user.id %>_last_name' ></div></p>
6
- <p><div id='user_<%= @user.id %>_email' ></div></p>
7
- <p><div id='user_<%= @user.id %>_phone' ></div></p>
8
- <div id='message'></div>
9
-
10
- <p>
11
- <% if @site.use_store %>
12
- <input type='button' value='Order History' class='btn' onclick="window.location='/my-account/orders';" />
13
- <% end %>
14
- </p>
2
+ <div id='my_account'>
3
+ <h1>My Account</h1>
4
+ <p><div id='user_<%= @user.id %>_first_name' ></div></p>
5
+ <p><div id='user_<%= @user.id %>_last_name' ></div></p>
6
+ <p><div id='user_<%= @user.id %>_email' ></div></p>
7
+ <p><div id='user_<%= @user.id %>_phone' ></div></p>
8
+ <div id='message'></div>
9
+ <p>
10
+ <% if @site.use_store %>
11
+ <input type='button' value='Order History' class='btn' onclick="window.location='/my-account/orders';" />
12
+ <% end %>
13
+ </p>
14
+ </div>
15
15
 
16
16
  <% content_for :caboose_js do %>
17
17
  <%= javascript_include_tag "caboose/model/all" %>
@@ -29,12 +29,17 @@ $(document).ready(function() {
29
29
  { name: 'email' , nice_name: 'Email' , type: 'text', value: <%= raw Caboose.json(@user.email) %>, width: 400 },
30
30
  { name: 'phone' , nice_name: 'Phone Number' , type: 'text', value: <%= raw Caboose.json(@user.phone) %>, width: 400 }
31
31
  ],
32
- on_load: function() { modal.autosize(); }
32
+ on_load: function() {
33
+ $('#user_<%= @user.id %>_first_name').css('width', '400px');
34
+ $('#user_<%= @user.id %>_last_name' ).css('width', '400px');
35
+ $('#user_<%= @user.id %>_email' ).css('width', '400px');
36
+ $('#user_<%= @user.id %>_phone' ).css('width', '400px');
37
+ }
33
38
  });
34
39
  });
35
40
 
36
41
  </script>
37
42
  <% end %>
38
43
  <%= content_for :caboose_css do %>
39
- <%= stylesheet_link_tag "caboose/my-account", :media => "all" %>
44
+ <%= stylesheet_link_tag "caboose/my_account", :media => "all" %>
40
45
  <% end %>
@@ -1,5 +1,9 @@
1
1
  <%
2
2
  captured = @order.financial_status == 'captured'
3
+ ba = @order.billing_address
4
+ sa = @order.shipping_address
5
+ ba = nil if ba.first_name.nil? || ba.last_name.nil?
6
+ sa = nil if sa.first_name.nil? || sa.last_name.nil?
3
7
  %>
4
8
  <input type='hidden' name='order_id' id='order_id' value='<%= @order.id %>' />
5
9
 
@@ -7,14 +11,14 @@ captured = @order.financial_status == 'captured'
7
11
 
8
12
  <table class='order'>
9
13
  <tr>
10
- <th>Billing Address</th>
11
- <th>Shipping Address</th>
14
+ <% if ba %><th>Billing Address</th><% end %>
15
+ <% if sa %><th>Shipping Address</th><% end %>
12
16
  <th>Order Status</th>
13
17
  <th>Payment Status</th>
14
18
  </tr>
15
19
  <tr>
16
- <td valign='top'><%= raw @order.billing_address.name_and_address %></td>
17
- <td valign='top'><%= raw @order.shipping_address.name_and_address %></td>
20
+ <% if ba %><td valign='top'><%= raw ba.name_and_address %></td><% end %>
21
+ <% if sa %><td valign='top'><%= raw sa.name_and_address %></td><% end %>
18
22
  <td valign='top'><%= @order.status.capitalize %></td>
19
23
  <td valign='top'><%= @order.financial_status.capitalize %></td>
20
24
  </tr>
@@ -50,19 +54,33 @@ captured = @order.financial_status == 'captured'
50
54
  </tr>
51
55
  <% end %>
52
56
  <% end %>
57
+ <% if @order.has_downloadable_items? %>
58
+ <tr>
59
+ <th>Item</th>
60
+ <th>Status</th>
61
+ <th>Unit Price</th>
62
+ <th>Quantity</th>
63
+ <th>Subtotal</th>
64
+ </tr>
65
+ <% end %>
53
66
  <% @order.line_items.each do |li| %>
54
- <% next if li.order_package_id %>
55
- <tr><td colspan='5'>Unpackaged Items</td></tr>
56
- <% img = li.variant.product_image %>
67
+ <% next if li.order_package_id %>
68
+ <% v = li.variant %>
69
+ <% if !v.downloadable %><tr><td colspan='5'>Unpackaged Items</td></tr><% end %>
70
+ <% img = v.product_image %>
57
71
  <tr>
58
72
  <td>
59
73
  <% if img %><img src='<%= img.url(:tiny) %>' /><% end %>
60
- <% if li.variant.nil? || li.variant.product.nil? %>
61
- <% if li.variant.nil? %>Unknown variant<% else %><%= li.variant.sku %><% end %>
74
+ <% if v.nil? || v.product.nil? %>
75
+ <% if v.nil? %>Unknown variant<% else %><%= v.sku %><% end %>
62
76
  <% else %>
63
- <a href='/admin/products/<%= li.variant.product.id %>'><%= li.variant.product.title %></a><br />
64
- <% if li.variant.sku && li.variant.sku.strip.length > 0 %><%= li.variant.sku %><br /><% end %>
65
- <%= li.variant.title %>
77
+ <p><a href='/admin/products/<%= v.product.id %>'><%= v.product.title %></a><br />
78
+ <% if v.sku && v.sku.strip.length > 0 %><%= v.sku %><br /><% end %>
79
+ <%= v.title %></p>
80
+ <% end %>
81
+ <% if v.downloadable %>
82
+ <% sc = @order.site.store_config %>
83
+ <p><a href='<%= raw sc.pp_relay_domain %>/my-account/orders/<%= @order.id %>/line-items/<%= li.id %>/download' target="_blank">Download</a></p>
66
84
  <% end %>
67
85
  </td>
68
86
  <td><%= li.status.capitalize %></td>
@@ -94,6 +112,8 @@ table.order td img { float: left; margin-right: 10px; }
94
112
  table.order td.package_header { font-weight: bold; text-align: center; border: 0; }
95
113
  table.order td.totals_header { font-weight: bold; text-align: center; border: 0; }
96
114
 
115
+ p { margin-bottom: 10px; }
116
+
97
117
  </style>
98
118
  <% end %>
99
119
 
@@ -11,7 +11,7 @@
11
11
  </tr>
12
12
  <% @orders.each do |order| %>
13
13
  <tr onclick="window.location='/my-account/orders/<%= order.id %>';">
14
- <td><%= order.date_created.strftime('%m/%d/%Y') %></td>
14
+ <td><%= order.date_created ? order.date_created.strftime('%m/%d/%Y') : '' %></td>
15
15
  <td><%= order.order_number %></td>
16
16
  <td><%= number_to_currency(order.total) %></td>
17
17
  <td><%= order.status.capitalize %></td>
@@ -27,7 +27,7 @@
27
27
  </td>
28
28
  <% end %>
29
29
  <td>
30
- <%= p.title %>
30
+ <p><%= p.title %></p>
31
31
  <% if li.is_gift %>
32
32
  <p>This item is a gift.</p>
33
33
  <ul>
@@ -35,6 +35,9 @@
35
35
  <li><% if li.include_gift_message %>Gift message: <%= li.gift_message %><% else %>No gift message<% end %></li>
36
36
  <li><% if li.hide_prices %>Hide all prices<% else %>Show all prices<% end %></li>
37
37
  </ul>
38
+ <% end %>
39
+ <% if li.variant.downloadable %>
40
+ <p><a href='<%= @order.site.store_config.pp_relay_domain %>/my-account/orders/<%= @order.id %>/line-items/<%= li.id %>/download' target="_blank">Download</a></li>
38
41
  <% end %>
39
42
  </td>
40
43
  <td align='right'><%= number_to_currency(li.unit_price) %></td>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.158'
2
+ VERSION = '0.5.159'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.158
4
+ version: 0.5.159
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-22 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -483,6 +483,7 @@ files:
483
483
  - app/assets/stylesheets/caboose/message_boxes.css.scss
484
484
  - app/assets/stylesheets/caboose/modal.css
485
485
  - app/assets/stylesheets/caboose/model_binder.css
486
+ - app/assets/stylesheets/caboose/my_account.css
486
487
  - app/assets/stylesheets/caboose/page_bar_generator.css
487
488
  - app/assets/stylesheets/caboose/print.css
488
489
  - app/assets/stylesheets/caboose/product_images.css.scss