Skip to content

Commit

Permalink
Make frontend prices depend on store.cart_tax_country_iso
Browse files Browse the repository at this point in the history
Prior to this change, prices in the frontend portion of Solidus would
depend on the setting for selecting prices in the backend, which is not
store-specific, but global. However, we want prices to be different in the
frontend if we change store and there are different prices.
  • Loading branch information
mamhoff committed Nov 25, 2016
1 parent cd5ca01 commit 51100ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Solidus 2.1.0 (master, unreleased)

* Make frontend prices depend on `store.cart_tax_country_iso`

Prices in the frontend now depend on `store.cart_tax_country_iso` instead of `Spree::Config.admin_vat_country_iso`.

* Deprecate methods related to Spree::Order#tax_zone

We're not using `Spree::Order#tax_zone`, `Spree::Zone.default_tax`,
Expand Down
3 changes: 2 additions & 1 deletion core/lib/spree/core/controller_helpers/pricing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module Pricing

def current_pricing_options
Spree::Config.pricing_options_class.new(
currency: current_store.try!(:default_currency).presence || Spree::Config[:currency]
currency: current_store.try!(:default_currency).presence || Spree::Config[:currency],
country_iso: current_store.try!(:cart_tax_country_iso).presence
)
end

Expand Down
16 changes: 16 additions & 0 deletions core/spec/lib/spree/core/controller_helpers/pricing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,21 @@ class FakesController < ApplicationController
it { is_expected.to eq('EUR') }
end
end

context "country_iso" do
subject { controller.current_pricing_options.country_iso }

let(:store) { FactoryGirl.create(:store, cart_tax_country_iso: cart_tax_country_iso) }

context "when the store has a cart tax country set" do
let(:cart_tax_country_iso) { "DE" }
it { is_expected.to eq("DE") }
end

context "when the store has no cart tax country set" do
let(:cart_tax_country_iso) { nil }
it { is_expected.to be_nil }
end
end
end
end

0 comments on commit 51100ef

Please sign in to comment.