Do not offer to create a new customer account if a membership is required

This commit is contained in:
Raphael Michel
2021-06-07 12:41:03 +02:00
parent 5ee51c8f9a
commit 881f0e04a0
2 changed files with 39 additions and 28 deletions

View File

@@ -254,6 +254,14 @@ class CustomerStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
field.widget.is_required = False field.widget.is_required = False
return f return f
@cached_property
def signup_allowed(self):
return not any(
p.item.require_membership or
(p.variation and p.variation.require_membership)
for p in self.positions
)
@cached_property @cached_property
def guest_allowed(self): def guest_allowed(self):
return not any( return not any(
@@ -330,6 +338,7 @@ class CustomerStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
self.cart_session.get('customer_mode', 'login' if self.request.customer else '') self.cart_session.get('customer_mode', 'login' if self.request.customer else '')
) )
ctx['guest_allowed'] = self.guest_allowed ctx['guest_allowed'] = self.guest_allowed
ctx['signup_allowed'] = self.signup_allowed
if 'customer' in self.cart_session: if 'customer' in self.cart_session:
try: try:

View File

@@ -14,7 +14,7 @@
<h4 class="panel-title"> <h4 class="panel-title">
<input type="radio" name="customer_mode" value="login" <input type="radio" name="customer_mode" value="login"
data-parent="#customer" data-parent="#customer"
{% if selected == "login" %}checked="checked"{% endif %} {% if selected == "login" or not signup_allowed %}checked="checked"{% endif %}
data-toggle="radiocollapse" data-target="#customer_login"/> data-toggle="radiocollapse" data-target="#customer_login"/>
<strong> <strong>
{% trans "Log in with a customer account" %} {% trans "Log in with a customer account" %}
@@ -23,7 +23,7 @@
</div> </div>
</label> </label>
<div id="customer_login" <div id="customer_login"
class="panel-collapse collapsed {% if selected == "login" %}in{% endif %}"> class="panel-collapse collapsed {% if selected == "login" or not signup_allowed %}in{% endif %}">
<div class="panel-body form-horizontal"> <div class="panel-body form-horizontal">
{% if customer %} {% if customer %}
<p> <p>
@@ -65,6 +65,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if signup_allowed %}
<div class="panel panel-default"> <div class="panel panel-default">
<label class="accordion-radio"> <label class="accordion-radio">
<div class="panel-heading"> <div class="panel-heading">
@@ -93,6 +94,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %}
{% if guest_allowed %} {% if guest_allowed %}
<div class="panel panel-default"> <div class="panel panel-default">
<label class="accordion-radio"> <label class="accordion-radio">