mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Hide guest checkout if deactivated
This commit is contained in:
@@ -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] || {}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user