Hide guest checkout if deactivated

This commit is contained in:
Maikel Linke
2016-09-23 15:05:46 +10:00
parent c59cd21698
commit 7c3968b64e
3 changed files with 27 additions and 8 deletions

View File

@@ -1,4 +1,8 @@
module CheckoutHelper
def guest_checkout_allowed?
current_order.distributor.allow_guest_orders?
end
def checkout_adjustments_for(order, opts={})
adjustments = order.adjustments.eligible
exclude = opts[:exclude] || {}

View File

@@ -4,11 +4,16 @@
%h3.pad-top
= t :checkout_headline
.row.pad-top
.small-5.columns.text-center
%button.primary.expand{"auth" => "login"}
= t :label_login
.small-2.columns.text-center
%p.pad-top= "-#{t :action_or}-"
.small-5.columns.text-center
%button.neutral-btn.dark.expand{"ng-click" => "enabled = true"}
= t :checkout_as_guest
-if guest_checkout_allowed?
.small-5.columns.text-center
%button.primary.expand{"auth" => "login"}
= t :label_login
.small-2.columns.text-center
%p.pad-top= "-#{t :action_or}-"
.small-5.columns.text-center
%button.neutral-btn.dark.expand{"ng-click" => "enabled = true"}
= t :checkout_as_guest
-else
.small-6.columns.small-centered
%button.primary.expand{"auth" => "login"}
= t :label_login

View File

@@ -20,4 +20,14 @@ describe CheckoutHelper do
helper.display_checkout_tax_total(order).should == Spree::Money.new(123.45, currency: 'AUD')
end
end
it "knows if guests can checkout" do
distributor = create(:distributor_enterprise)
order = create(:order, distributor: distributor)
helper.stub(:current_order) { order }
expect(helper.guest_checkout_allowed?).to be true
order.distributor.allow_guest_orders = false
expect(helper.guest_checkout_allowed?).to be false
end
end