diff --git a/hub/services/templates/services/embedded_contact_form.html b/hub/services/templates/services/embedded_contact_form.html
index d0f719d..5d22f21 100644
--- a/hub/services/templates/services/embedded_contact_form.html
+++ b/hub/services/templates/services/embedded_contact_form.html
@@ -54,6 +54,17 @@
{% endif %}
+ {% if choices %}
+
+
+
+
+ {% endif %}
+
{{ form.message|addclass:"form-control" }}
diff --git a/hub/services/templates/services/offering_detail.html b/hub/services/templates/services/offering_detail.html
index 9fbd3e0..daae63c 100644
--- a/hub/services/templates/services/offering_detail.html
+++ b/hub/services/templates/services/offering_detail.html
@@ -149,11 +149,6 @@
{% endif %}
-
-
Order This Plan
- {% load contact_tags %}
- {% embedded_contact_form source="Plan Order" service=offering.service offering_id=offering.id plan_id=plan.id %}
-
{% empty %}
@@ -167,6 +162,18 @@
{% endfor %}
+
+ {% if offering.plans.exists %}
+
+
I'm interested in a plan
+
+
+ {% load contact_tags %}
+ {% embedded_contact_form source="Plan Order" service=offering.service offering_id=offering.id choices=offering.plans.all choice_label="Select a Plan" %}
+
+
+
+ {% endif %}
diff --git a/hub/services/templatetags/contact_tags.py b/hub/services/templatetags/contact_tags.py
index 748a2cb..6d7791b 100644
--- a/hub/services/templatetags/contact_tags.py
+++ b/hub/services/templatetags/contact_tags.py
@@ -8,7 +8,14 @@ register = template.Library()
@register.inclusion_tag("services/embedded_contact_form.html", takes_context=True)
def embedded_contact_form(
- context, source=None, details=None, service=None, offering_id=None, plan_id=None
+ context,
+ source=None,
+ details=None,
+ service=None,
+ offering_id=None,
+ plan_id=None,
+ choices=None,
+ choice_label=None,
):
"""
Renders an embedded contact form with optional service context information.
@@ -17,6 +24,7 @@ def embedded_contact_form(
{% load contact_tags %}
{% embedded_contact_form source="Partner Page" details="ACME Corp" %}
{% embedded_contact_form service=service offering_id=offering.id plan_id=plan.id %}
+ {% embedded_contact_form service=service offering_id=offering.id choices=offering.plans.all choice_label="Select a Plan" %}
"""
request = context["request"]
form = LeadForm()
@@ -25,6 +33,11 @@ def embedded_contact_form(
offering_obj = None
plan_obj = None
+ # Process choices if they're QuerySet objects (like plans)
+ processed_choices = None
+ if choices:
+ processed_choices = [(str(choice.id), choice.name) for choice in choices]
+
# Resolve service/offering/plan objects if IDs provided
if service and isinstance(service, str):
try:
@@ -56,4 +69,6 @@ def embedded_contact_form(
"offering": offering_obj,
"plan": plan_obj,
"request": request,
+ "choices": processed_choices,
+ "choice_label": choice_label,
}
diff --git a/hub/services/views/leads.py b/hub/services/views/leads.py
index 72108b4..00ce109 100644
--- a/hub/services/views/leads.py
+++ b/hub/services/views/leads.py
@@ -26,7 +26,7 @@ def contact_form(request):
lead = Lead(
name=form.cleaned_data["name"],
email=form.cleaned_data["email"],
- message=form.cleaned_data["message"],
+ message=form.cleaned_data["message"] or "",
company=form.cleaned_data["company"],
phone=form.cleaned_data["phone"],
)
@@ -87,6 +87,22 @@ def contact_form(request):
if plan_name:
service_info.append(f"Plan: {plan_name}")
+ # Handle selected choice if present
+ selected_choice = request.POST.get("selected_choice", "")
+ if selected_choice:
+ try:
+ choice_id, choice_name = selected_choice.split("|", 1)
+ # Add selected choice to message
+ service_info.append(f"Selected Plan: {choice_name}")
+
+ # Try to set the plan based on the choice_id
+ try:
+ lead.plan = Plan.objects.get(id=choice_id)
+ except Plan.DoesNotExist:
+ pass
+ except ValueError:
+ pass
+
if service_info:
context_info.append("Service Information: " + ", ".join(service_info))