Skip to content

Commit

Permalink
Merge pull request #476 from commonknowledge/gift-purchase-flow-impro…
Browse files Browse the repository at this point in the history
…vements

Return all countries (not shipping zones) when user is buying a gift subscription
  • Loading branch information
Moggach authored Jul 22, 2024
2 parents a9b6ca3 + 292c578 commit 2217772
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/templates/app/frames/shipping_cost.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>
{% bootstrap_alert "This subscription will automatically renew, and you can cancel at any time." dismissible=False alert_type="success" extra_classes='mb-2' %}
{% if request.GET.gift_mode %}
{% bootstrap_alert "At checkout, please add your own shipping address, in case we need to send you any gift card materials. Your gift recipient will be able to enter their own address when they redeem." dismissible=False alert_type="warning" extra_classes='mb-2' %}
{% bootstrap_alert "At checkout, please add your own shipping address, in case we need to send you any gift card materials. Your gift recipient will be able to enter their own address when they redeem." dismissible=False alert_type="warning" extra_classes='mb-2 text-light bg-danger' %}
{% endif %}
{% if user.is_member and not request.GET.gift_mode %}
<div class='justify-content-center'>
Expand All @@ -52,7 +52,7 @@
type="checkbox"
value=""
id='confirm_cancel_current_subscriptions'
name='confirm_cancel_current_subscriptions'/>
name='confirm_cancel_current_subscriptions' />
<label class="form-check-label" for="confirm_cancel_current_subscriptions">
<p>
I understand that my existing membership plan ({{ user.primary_product.name }}) will be <u>immediately cancelled</u> and replaced with this new subscription
Expand Down
11 changes: 11 additions & 0 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from sentry_sdk import capture_exception, capture_message
from wagtail.models import Page


from app import analytics
from app.forms import (
CountrySelectorForm,
Expand Down Expand Up @@ -587,6 +588,7 @@ def get_context_data(self, price_id, product_id, country_id="GB", **kwargs):
}

return context



class SubscriptionCheckoutView(TemplateView):
Expand Down Expand Up @@ -628,6 +630,11 @@ def create_checkout_context(
next = "/"
if gift_mode:
checkout_args["metadata"]["gift_mode"] = True

checkout_args["shipping_address_collection"] = {
"allowed_countries": ShippingZone.all_country_codes

}
next = reverse_lazy("completed_gift_purchase")
else:
next = reverse_lazy("completed_membership_purchase")
Expand Down Expand Up @@ -1290,6 +1297,10 @@ def create_checkout_context(
next = "/"
if gift_mode:
checkout_args["metadata"]["gift_mode"] = True
checkout_args["shipping_address_collection"] = {
"allowed_countries": ShippingZone.all_country_codes

}
next = reverse_lazy("completed_gift_purchase")
else:
next = reverse_lazy("completed_membership_purchase")
Expand Down

0 comments on commit 2217772

Please sign in to comment.