Class: Spree::ShippingRate
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/shipping_rate.rb
Instance Method Summary collapse
- #display_price ⇒ Object (also: #display_cost)
-
#final_price ⇒ Object
returns base price - any available discounts for this Shipment useful when you want to present a list of available shipping rates.
- #tax_amount ⇒ Object
Methods included from DisplayMoney
Methods inherited from Base
belongs_to_required_by_default, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope
Methods included from Preferences::Preferable
#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference
Instance Method Details
#display_price ⇒ Object Also known as: display_cost
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/spree/shipping_rate.rb', line 14 def display_price price = display_base_price.to_s return price if tax_rate.nil? || tax_amount.zero? Spree.t( tax_rate.included_in_price? ? :including_tax : :excluding_tax, scope: 'shipping_rates.display_price', price: price, tax_amount: display_tax_amount, tax_rate_name: tax_rate.name ) end |
#final_price ⇒ Object
returns base price - any available discounts for this Shipment useful when you want to present a list of available shipping rates
36 37 38 39 40 41 42 |
# File 'app/models/spree/shipping_rate.rb', line 36 def final_price if free? || cost < -discount_amount BigDecimal(0) else cost + discount_amount end end |
#tax_amount ⇒ Object
30 31 32 |
# File 'app/models/spree/shipping_rate.rb', line 30 def tax_amount @tax_amount ||= tax_rate&.calculator&.compute_shipping_rate(self) || BigDecimal(0) end |