Class: Spree::ShippingRate
- Inherits:
-
Object
- Object
- Spree::ShippingRate
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/shipping_rate.rb
Instance Method Summary collapse
-
#additional_tax_total ⇒ BigDecimal
Returns the additional tax total for the shipping rate.
-
#delivery_range ⇒ String
Returns the delivery range for the shipping method.
-
#display_delivery_range ⇒ String
Returns the display delivery range for the shipping method.
- #display_price ⇒ Object (also: #display_cost)
-
#final_price ⇒ Object
(also: #total)
returns base price - any available discounts for this Shipment useful when you want to present a list of available shipping rates.
-
#free? ⇒ Boolean
Returns true if the shipping rate is free.
-
#included_tax_total ⇒ BigDecimal
Returns the included tax total for the shipping rate.
-
#tax_amount ⇒ BigDecimal
(also: #tax_total)
Returns the tax amount for the shipping rate.
Methods included from DisplayMoney
Instance Method Details
#additional_tax_total ⇒ BigDecimal
Returns the additional tax total for the shipping rate
49 50 51 |
# File 'app/models/spree/shipping_rate.rb', line 49 def additional_tax_total tax_rate&.included_in_price? ? BigDecimal(0) : tax_amount end |
#delivery_range ⇒ String
Returns the delivery range for the shipping method
78 79 80 81 82 |
# File 'app/models/spree/shipping_rate.rb', line 78 def delivery_range return unless shipping_method.delivery_range shipping_method.delivery_range end |
#display_delivery_range ⇒ String
Returns the display delivery range for the shipping method
87 88 89 90 91 |
# File 'app/models/spree/shipping_rate.rb', line 87 def display_delivery_range return unless delivery_range Spree.t(:display_delivery_range, delivery_range: delivery_range) end |
#display_price ⇒ Object Also known as: display_cost
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/spree/shipping_rate.rb', line 16 def display_price price = display_base_price.to_s return price if tax_rate.nil? || tax_amount.zero? || !tax_rate.show_rate_in_label 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 Also known as: total
returns base price - any available discounts for this Shipment useful when you want to present a list of available shipping rates
65 66 67 68 69 70 71 |
# File 'app/models/spree/shipping_rate.rb', line 65 def final_price if with_free_shipping_promotion? || cost < -discount_amount BigDecimal(0) else cost + discount_amount end end |
#free? ⇒ Boolean
Returns true if the shipping rate is free
35 36 37 |
# File 'app/models/spree/shipping_rate.rb', line 35 def free? final_price.zero? end |
#included_tax_total ⇒ BigDecimal
Returns the included tax total for the shipping rate
56 57 58 |
# File 'app/models/spree/shipping_rate.rb', line 56 def included_tax_total tax_rate&.included_in_price? ? tax_amount : BigDecimal(0) end |
#tax_amount ⇒ BigDecimal Also known as: tax_total
Returns the tax amount for the shipping rate
42 43 44 |
# File 'app/models/spree/shipping_rate.rb', line 42 def tax_amount @tax_amount ||= tax_rate&.calculator&.compute_shipping_rate(self) || BigDecimal(0) end |