caboose-cms 0.5.133 → 0.5.134
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/checkout_controller.rb +1 -1
- data/app/controllers/caboose/order_packages_controller.rb +1 -1
- data/app/models/caboose/order.rb +2 -6
- data/app/models/caboose/order_package.rb +12 -7
- data/app/models/caboose/order_pdf.rb +1 -1
- data/app/models/caboose/shipping_calculator.rb +14 -9
- data/app/models/caboose/shipping_package.rb +1 -1
- data/app/views/caboose/checkout/payment.html.erb +1 -1
- data/app/views/caboose/checkout/shipping.html.erb +4 -5
- data/app/views/caboose/my_account_orders/edit.html.erb +1 -1
- data/app/views/caboose/variants/admin_edit.html.erb +8 -6
- data/app/views/caboose/variants/admin_index.html.erb +5 -4
- data/app/views/layouts/caboose/application.html.erb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTllOWRlNjc2MzU1MDk1YTVkNjBkMmIxZDVkNWJkZTA2NDBiYjdmMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDUxNDA2OTY3MGE4MTYxZDdmOTVhOTY0ODZmNWY5Y2M5NGY2ZjBhYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjExMjk4OTYxMWVlNTEwNTE1NDJkYzk4ZTQxYTU0NDZiODEyZjJhMTgzYzky
|
10
|
+
NTAzZDU5YmM3ZDVmMTk4MmQyNTdjMDA0MTVlMTJhMjg1Y2Q5Yzk0ZmFiMjM3
|
11
|
+
NmMwM2ZiZjRhYzY5ZDA2YmUwODEwY2JhODQzYzM4MTdhZDhkNzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTJmNmZmMjU5YzgzN2JkNGU5NTJlZmVlMmYxOTdlZjhiZjUxYjM5ZGNjN2Jh
|
14
|
+
NzI0YzJlYzk4MzNiYmNlMmY4OTA1OThjMWVhMjgwNGVmMjU4MjFmNjg3MDJi
|
15
|
+
ODJjMWZjMTRkOGFlZDA2ODM5OGYzYWFkMzEyNmJjNWU5MzU1ZjE=
|
@@ -5,7 +5,7 @@ module Caboose
|
|
5
5
|
def admin_json
|
6
6
|
return if !user_is_allowed('orders', 'view')
|
7
7
|
order = Order.find(params[:order_id])
|
8
|
-
render :json => order.
|
8
|
+
render :json => order.order_packages.as_json(
|
9
9
|
:include => { :shipping_package => { :include => :shipping_methods} }
|
10
10
|
)
|
11
11
|
end
|
data/app/models/caboose/order.rb
CHANGED
@@ -91,10 +91,6 @@ module Caboose
|
|
91
91
|
self.discount = 0.00 if self.discount.nil?
|
92
92
|
self.total = 0.00 if self.total.nil?
|
93
93
|
end
|
94
|
-
|
95
|
-
def packages
|
96
|
-
self.order_packages
|
97
|
-
end
|
98
94
|
|
99
95
|
def decrement_quantities
|
100
96
|
return false if self.decremented
|
@@ -166,7 +162,7 @@ module Caboose
|
|
166
162
|
def calculate_shipping
|
167
163
|
return 0.0 if self.order_packages.nil? || self.order_packages.count == 0
|
168
164
|
x = 0.0
|
169
|
-
self.order_packages.each{ |op| x = x + op.total }
|
165
|
+
self.order_packages.all.each{ |op| x = x + op.total }
|
170
166
|
return x
|
171
167
|
end
|
172
168
|
|
@@ -219,7 +215,7 @@ module Caboose
|
|
219
215
|
def has_empty_shipping_methods?
|
220
216
|
return true if self.order_packages.nil?
|
221
217
|
return true if self.order_packages.count == 0
|
222
|
-
self.order_packages.each do |op|
|
218
|
+
self.order_packages.all.each do |op|
|
223
219
|
return true if op.shipping_method_id.nil?
|
224
220
|
end
|
225
221
|
return false
|
@@ -73,16 +73,17 @@ module Caboose
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
line_items = h.sort_by{ |k,v| k }.collect{ |x| x[1] }
|
76
|
-
all_packages = ShippingPackage.reorder(:flat_rate_price).all
|
76
|
+
all_packages = ShippingPackage.where(:site_id => order.site_id).reorder(:flat_rate_price).all
|
77
77
|
|
78
78
|
# Now go through each variant and fit it in a new or existing package
|
79
79
|
line_items.each do |li|
|
80
|
+
next if li.variant.downloadable
|
80
81
|
|
81
82
|
# See if the item will fit in any of the existing packages
|
82
83
|
it_fits = false
|
83
|
-
order.
|
84
|
+
order.order_packages.all.each do |op|
|
84
85
|
it_fits = op.fits(li)
|
85
|
-
if it_fits
|
86
|
+
if it_fits
|
86
87
|
li.order_package_id = op.id
|
87
88
|
li.save
|
88
89
|
break
|
@@ -91,16 +92,20 @@ module Caboose
|
|
91
92
|
next if it_fits
|
92
93
|
|
93
94
|
# Otherwise find the cheapest package the item will fit into
|
94
|
-
|
95
|
-
|
95
|
+
it_fits = false
|
96
|
+
all_packages.each do |sp|
|
97
|
+
it_fits = sp.fits(li.variant)
|
98
|
+
if it_fits
|
96
99
|
op = OrderPackage.create(:order_id => order.id, :shipping_package_id => sp.id)
|
97
100
|
li.order_package_id = op.id
|
98
101
|
li.save
|
99
102
|
break
|
100
103
|
end
|
101
104
|
end
|
102
|
-
|
103
|
-
|
105
|
+
next if it_fits
|
106
|
+
|
107
|
+
Caboose.log("Error: line item #{li.id} (#{li.variant.product.title}) does not fit into any package.")
|
108
|
+
end
|
104
109
|
end
|
105
110
|
|
106
111
|
def fits(line_item = nil)
|
@@ -9,8 +9,8 @@ module Caboose
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.rates(order)
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
return [] if order.site.nil? || order.site.store_config.nil?
|
14
14
|
sc = order.site.store_config
|
15
15
|
if sc.shipping_rates_function
|
16
16
|
rates = self.custom_rates(sc, order)
|
@@ -33,23 +33,28 @@ module Caboose
|
|
33
33
|
carriers['UPS'] = UPS.new( :login => sc.ups_username, :password => sc.ups_password, :key => sc.ups_key, :origin_account => sc.ups_origin_account) if sc.ups_username && sc.ups_username.strip.length > 0
|
34
34
|
carriers['USPS'] = USPS.new( :login => sc.usps_username) if sc.usps_username && sc.usps_username.strip.length > 0
|
35
35
|
carriers['FedEx'] = FedEx.new(:login => sc.fedex_username, :password => sc.fedex_password, :key => sc.fedex_key, :account => sc.fedex_account) if sc.fedex_username && sc.fedex_username.strip.length > 0
|
36
|
-
|
37
|
-
all_rates = []
|
38
|
-
order.
|
36
|
+
|
37
|
+
all_rates = []
|
38
|
+
order.order_packages.all.each do |op|
|
39
39
|
sp = op.shipping_package
|
40
40
|
package = op.activemerchant_package
|
41
41
|
rates = []
|
42
|
-
carriers.each do |name, carrier|
|
42
|
+
carriers.each do |name, carrier|
|
43
|
+
Caboose.log("Looking at carrier #{name}")
|
43
44
|
if sp.uses_carrier(name)
|
44
|
-
|
45
|
-
resp.
|
46
|
-
|
45
|
+
Caboose.log("Shipping package does use carrier #{name}.")
|
46
|
+
resp = carrier.find_rates(origin, destination, package)
|
47
|
+
resp.rates.sort_by(&:price).each do |rate|
|
48
|
+
sm = ShippingMethod.where( :carrier => name, :service_code => rate.service_code, :service_name => rate.service_name).first
|
47
49
|
sm = ShippingMethod.create(:carrier => name, :service_code => rate.service_code, :service_name => rate.service_name) if sm.nil?
|
48
50
|
next if !sp.uses_shipping_method(sm)
|
49
51
|
rates << { :shipping_method => sm, :price => rate.total_price.to_d / 100 }
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
55
|
+
if rates.count == 0
|
56
|
+
Caboose.log("Error: no shipping rates found for order package #{op.id}.")
|
57
|
+
end
|
53
58
|
all_rates << { :order_package => op, :rates => rates }
|
54
59
|
end
|
55
60
|
return all_rates
|
@@ -40,7 +40,7 @@ module Caboose
|
|
40
40
|
return false if (rigid_volume + floppy_volume) > self.volume
|
41
41
|
rigid_boxes = self.boxes(rigid)
|
42
42
|
|
43
|
-
it_fits = false
|
43
|
+
it_fits = false
|
44
44
|
BoxPacker.container [self.inside_length, self.inside_width, self.inside_height] do
|
45
45
|
rigid_boxes.each{ |arr| add_item arr }
|
46
46
|
count = pack!
|
@@ -90,7 +90,7 @@ store_config = @site.store_config
|
|
90
90
|
<% if @order.has_shippable_items? %>
|
91
91
|
<section id='shipping_method'>
|
92
92
|
<h3>Shipping</h3>
|
93
|
-
<% @order.order_packages.each do |op| %>
|
93
|
+
<% @order.order_packages.all.each do |op| %>
|
94
94
|
<p><%= op.shipping_method.service_name %> - <%= number_to_currency(op.total) %></p>
|
95
95
|
<% end %>
|
96
96
|
<p><a href="/checkout/shipping">Edit</a></p>
|
@@ -1,10 +1,9 @@
|
|
1
1
|
|
2
2
|
<h1>Shipping Rates</h1>
|
3
|
-
<div id="checkout">
|
4
|
-
<%
|
5
|
-
|
6
|
-
%>
|
7
|
-
<% if @rates.count == 1 %>
|
3
|
+
<div id="checkout">
|
4
|
+
<% if @rates.count == 0 %>
|
5
|
+
<p>It looks like no rates were returned. Please contact the site adminstrator.</p>
|
6
|
+
<% elsif @rates.count == 1 %>
|
8
7
|
<p>Please select which shipping method you'd like to use.</p>
|
9
8
|
<p>
|
10
9
|
<% op = @rates[0][:order_package] %>
|
@@ -21,7 +21,7 @@ captured = @order.financial_status == 'captured'
|
|
21
21
|
</table><br />
|
22
22
|
|
23
23
|
<table class='order' width='100%'>
|
24
|
-
<% @order.
|
24
|
+
<% @order.order_packages.all.each_with_index do |op, i| %>
|
25
25
|
<tr><td colspan='5' class='package_header'>Package <%= (i+1) %>: <%= op.shipping_method.service_name %><br /><%= op.status %></td></tr>
|
26
26
|
<tr>
|
27
27
|
<th>Item</th>
|
@@ -26,8 +26,8 @@ v = @variant
|
|
26
26
|
<div id='variant_<%= v.id %>_ignore_quantity' ></div>
|
27
27
|
</td><td valign='top'>
|
28
28
|
<h2>Dimensions</h2>
|
29
|
-
<div id='variant_<%= v.id %>_weight' ></div>
|
30
29
|
<div id='variant_<%= v.id %>_cylinder' ></div>
|
30
|
+
<div id='variant_<%= v.id %>_weight' ></div>
|
31
31
|
<div id='variant_<%= v.id %>_length' ></div>
|
32
32
|
<div id='variant_<%= v.id %>_width' ></div>
|
33
33
|
<div id='variant_<%= v.id %>_height' ></div>
|
@@ -53,7 +53,9 @@ v = @variant
|
|
53
53
|
<%= javascript_include_tag "caboose/model/all" %>
|
54
54
|
<%= javascript_include_tag "caboose/admin_products" %>
|
55
55
|
<script type='text/javascript'>
|
56
|
-
|
56
|
+
<%
|
57
|
+
sc = @site.store_config
|
58
|
+
%>
|
57
59
|
$(document).ready(function() {
|
58
60
|
m = new ModelBinder({
|
59
61
|
name: 'Variant',
|
@@ -73,10 +75,10 @@ $(document).ready(function() {
|
|
73
75
|
{ name: 'date_sale_ends' , nice_name: 'Sale ends' , type: 'datetime' , align: 'right' , value: <%= raw Caboose.json(v.date_sale_ends ? v.date_sale_ends.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %>, width: 275 },
|
74
76
|
{ name: 'quantity_in_stock' , nice_name: 'Quantity' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.quantity_in_stock ) %>, width: 250 },
|
75
77
|
{ name: 'ignore_quantity' , nice_name: 'Ignore Quantity' , type: 'checkbox' , align: 'right' , value: <%= raw Caboose.json(v.ignore_quantity ) %>, width: 250 },
|
76
|
-
{ name: 'weight' , nice_name: 'Weight (
|
77
|
-
{ name: 'length' , nice_name: 'Length (
|
78
|
-
{ name: 'width' , nice_name: 'Width (
|
79
|
-
{ name: 'height' , nice_name: 'Height (
|
78
|
+
{ name: 'weight' , nice_name: 'Weight (<%= sc.weight_unit %>)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.weight ) %>, width: 250 },
|
79
|
+
{ name: 'length' , nice_name: 'Length (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.length ) %>, width: 250 },
|
80
|
+
{ name: 'width' , nice_name: 'Width (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.width ) %>, width: 250 },
|
81
|
+
{ name: 'height' , nice_name: 'Height (<%= sc.length_unit %>)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.height ) %>, width: 250 },
|
80
82
|
{ name: 'cylinder' , nice_name: 'Cylinder' , type: 'checkbox' , align: 'right' , value: <%= raw Caboose.json(v.cylinder ) %>, width: 250 },
|
81
83
|
{ name: 'requires_shipping' , nice_name: 'Requires shipping' , type: 'checkbox' , align: 'right' , value: <%= raw Caboose.json(v.requires_shipping ) %>, width: 250 },
|
82
84
|
{ name: 'taxable' , nice_name: 'Taxable' , type: 'checkbox' , align: 'right' , value: <%= raw Caboose.json(v.taxable ) %>, width: 250 },
|
@@ -52,6 +52,7 @@ fields = ['Alternate ID', 'Quantity In Stock', 'Price']
|
|
52
52
|
fields << p.option1 if p.option1
|
53
53
|
fields << p.option2 if p.option2
|
54
54
|
fields << p.option3 if p.option3
|
55
|
+
sc = @site.store_config
|
55
56
|
%>
|
56
57
|
|
57
58
|
$(document).ready(function() {
|
@@ -77,10 +78,10 @@ $(document).ready(function() {
|
|
77
78
|
{ show: false , name: 'date_sale_starts' , nice_name: 'Sale starts' , sort: 'date_sale_starts' , type: 'datetime' , value: function(v) { return v.date_sale_starts }, width: 75, align: 'left' , bulk_edit: true },
|
78
79
|
{ show: false , name: 'date_sale_ends' , nice_name: 'Sale ends' , sort: 'date_sale_ends' , type: 'datetime' , value: function(v) { return v.date_sale_ends }, width: 75, align: 'left' , bulk_edit: true },
|
79
80
|
{ show: true , name: 'quantity_in_stock' , nice_name: 'Quantity' , sort: 'quantity_in_stock' , type: 'text' , value: function(v) { return v.quantity_in_stock }, width: 50, align: 'right' , bulk_edit: true },
|
80
|
-
{ show: false , name: 'weight' , nice_name: 'Weight (
|
81
|
-
{ show: false , name: 'length' , nice_name: 'Length (
|
82
|
-
{ show: false , name: 'width' , nice_name: 'Width (
|
83
|
-
{ show: false , name: 'height' , nice_name: 'Height (
|
81
|
+
{ show: false , name: 'weight' , nice_name: 'Weight (<%= sc.weight_unit %>)' , sort: 'weight' , type: 'text' , value: function(v) { return v.weight }, width: 50, align: 'right' , bulk_edit: true },
|
82
|
+
{ show: false , name: 'length' , nice_name: 'Length (<%= sc.length_unit %>)' , sort: 'length' , type: 'text' , value: function(v) { return v.length }, width: 50, align: 'right' , bulk_edit: true },
|
83
|
+
{ show: false , name: 'width' , nice_name: 'Width (<%= sc.length_unit %>)' , sort: 'width' , type: 'text' , value: function(v) { return v.width }, width: 50, align: 'right' , bulk_edit: true },
|
84
|
+
{ show: false , name: 'height' , nice_name: 'Height (<%= sc.length_unit %>)' , sort: 'height' , type: 'text' , value: function(v) { return v.height }, width: 50, align: 'right' , bulk_edit: true },
|
84
85
|
{ show: false , name: 'cylinder' , nice_name: 'Cylinder' , sort: 'cylinder' , type: 'checkbox' , value: function(v) { return v.cylinder }, text: function(v) { return v.cylinder ? 'Yes' : 'No' }, width: 50, align: 'center' , bulk_edit: true },
|
85
86
|
{ show: false , name: 'requires_shipping' , nice_name: 'Requires shipping' , sort: 'requires_shipping' , type: 'checkbox' , value: function(v) { return v.requires_shipping }, text: function(v) { return v.requires_shipping ? 'Yes' : 'No' }, width: 50, align: 'center' , bulk_edit: true },
|
86
87
|
{ show: false , name: 'taxable' , nice_name: 'Taxable' , sort: 'taxable' , type: 'checkbox' , value: function(v) { return v.taxable }, text: function(v) { return v.taxable ? 'Yes' : 'No' }, width: 50, align: 'center' , bulk_edit: true },
|
data/lib/caboose/version.rb
CHANGED