Skip to content

Commit

Permalink
Merge pull request #2306 from jhawthorn/improve_shpping_rate_tax_disp…
Browse files Browse the repository at this point in the history
…lay_price

Improve ShippingRate#display_price with taxes
  • Loading branch information
jhawthorn authored Oct 20, 2017
2 parents 531445c + ef2e350 commit ec5eca5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Shipment < Spree::Base

has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :delete_all
has_many :inventory_units, dependent: :destroy, inverse_of: :shipment
has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy
has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy, inverse_of: :shipment
has_many :shipping_methods, through: :shipping_rates
has_many :state_changes, as: :stateful
has_many :cartons, -> { uniq }, through: :inventory_units
Expand Down
3 changes: 2 additions & 1 deletion core/app/models/spree/shipping_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ShippingRate < Spree::Base
has_many :taxes,
class_name: "Spree::ShippingRateTax",
foreign_key: "shipping_rate_id",
inverse_of: :shipping_rate,
dependent: :destroy

delegate :order, :currency, to: :shipment
Expand All @@ -26,7 +27,7 @@ class ShippingRate < Spree::Base
def display_price
price = display_amount.to_s

return price if taxes.empty? || amount == 0
return price if taxes.to_a.empty? || amount == 0

tax_explanations = taxes.map(&:label).join(tax_label_separator)

Expand Down

0 comments on commit ec5eca5

Please sign in to comment.