Class: Caboose::OrderPackageCalculator
- Inherits:
-
Object
- Object
- Caboose::OrderPackageCalculator
- Defined in:
- app/models/caboose/order_package_calculator.rb
Class Method Summary collapse
- .custom_order_packages(store_config, order) ⇒ Object
- .order_packages(order) ⇒ Object
- .rate(order) ⇒ Object
Class Method Details
.custom_order_packages(store_config, order) ⇒ Object
7 8 9 |
# File 'app/models/caboose/order_package_calculator.rb', line 7 def self.custom_order_packages(store_config, order) return eval(store_config.order_packages_function) end |
.order_packages(order) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/caboose/order_package_calculator.rb', line 11 def self.order_packages(order) return [] if Caboose::store_shipping.nil? sc = order.site.store_config if sc.order_packages_function order_packages = self.custom_order_packages(sc, order) return order_packages end # Remove any order packages LineItem.where(:order_id => order.id).update_all(:order_package_id => nil) OrderPackage.where(:order_id => order.id).destroy_all # Calculate what shipping packages we'll need OrderPackage.create_for_order(order) return all_rates end |
.rate(order) ⇒ Object
30 31 32 33 34 |
# File 'app/models/caboose/order_package_calculator.rb', line 30 def self.rate(order) return nil if !order.shipping_service_code self.rates(order).each { |rate| return rate if rate[:service_code] == order.shipping_service_code } return nil end |