Class: SpreePacketa::Models::ShippingCalculator
- Inherits:
-
Spree::ShippingCalculator
- Object
- Spree::ShippingCalculator
- SpreePacketa::Models::ShippingCalculator
- Defined in:
- lib/spree_packeta/models/shipping_calculator.rb
Instance Method Summary collapse
-
#compute_package(package) ⇒ BigDecimal
Calculate shipping rate for a package.
Instance Method Details
#compute_package(package) ⇒ BigDecimal
Calculate shipping rate for a package
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spree_packeta/models/shipping_calculator.rb', line 14 def compute_package(package) return 0 if package.contents.empty? # For Phase 1, use fixed rate from preferences # Phase 2 will implement dynamic rate calculation via Packeta API base_rate = BigDecimal(preferred_amount.to_s) # Apply weight-based multiplier if needed total_weight = calculate_total_weight(package) weight_multiplier = calculate_weight_multiplier(total_weight) (base_rate * weight_multiplier).round(2) end |