My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
159
attachment: SubstructShippingBugfix.patch
(1.0 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/vendor/plugins/substruct/app/models/order_shipping_type.rb b/vendor/plugins/substruct/app/models/order_shipping_type.rb
index 6686ccf..2b031e3 100755
--- a/vendor/plugins/substruct/app/models/order_shipping_type.rb
+++ b/vendor/plugins/substruct/app/models/order_shipping_type.rb
@@ -46,13 +46,23 @@ class OrderShippingType < ActiveRecord::Base
def calculate_price(weight)
price = self.price
+ overflow_price = 0
if self.weights.size > 0
+
+ max_weight_item = self.weights[-1]
+ while (weight > max_weight_item.max_weight)
+ overflow_price += max_weight_item.price
+ weight -= max_weight_item.max_weight
+ end
+
proper_weight = self.weights.find(
:first,
:conditions => ["? BETWEEN min_weight AND max_weight", weight]
)
price = proper_weight.price if proper_weight
+
+ price += overflow_price
end
self.calculated_price = price + Preference.find_by_name('store_handling_fee').value.to_f
Powered by
Google Project Hosting