Class: Spree::DeliveryRateProvider::Internal
- Defined in:
- app/models/spree/delivery_rate_provider/internal.rb
Overview
Default provider: prices through the delivery method's calculator, so every store that doesn't opt into an external provider behaves exactly as before. Custom merchant calculators keep working unchanged, including the ones that suppress a method by returning nil.
Carries no carrier metadata and no delivery date: turning the method's configured business days into a date needs a per-market holiday calendar core doesn't have, and guessing one would put a wrong date in front of customers. Carrier-backed providers return the real date.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.uses_calculator? ⇒ Boolean
The calculator is the whole point of this provider.
Instance Method Summary collapse
Methods inherited from Base
#book, #estimates, #initialize, #release, requires_address?, service_catalog
Methods included from ApiTyped
#api_type, api_type_for, #api_typed_family, class_name_for, find, registered_class
Methods included from IntegrationBackedProvider
Constructor Details
This class inherits a constructor from Spree::DeliveryRateProvider::Base
Class Method Details
.uses_calculator? ⇒ Boolean
The calculator is the whole point of this provider.
14 15 16 |
# File 'app/models/spree/delivery_rate_provider/internal.rb', line 14 def self.uses_calculator? true end |
Instance Method Details
#estimate(package) ⇒ Spree::DeliveryRateProvider::Estimate?
20 21 22 23 24 25 |
# File 'app/models/spree/delivery_rate_provider/internal.rb', line 20 def estimate(package) cost = delivery_method.calculator.compute(package) return if cost.nil? Estimate.new(cost: cost) end |