From 21cf3011fc12c9f53b1626d17ff475d2d4c9e87e Mon Sep 17 00:00:00 2001 From: Jan Baykara Date: Mon, 9 May 2022 02:00:23 +0100 Subject: [PATCH] Tag subscriptions with primary product to make automations easier --- app/models/wagtail.py | 2 ++ app/views.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/wagtail.py b/app/models/wagtail.py index 85d0e11c..7f576b3e 100644 --- a/app/models/wagtail.py +++ b/app/models/wagtail.py @@ -282,12 +282,14 @@ def to_checkout_line_items(self, zone=None, product=None): { "price_data": self.to_price_data(product), "quantity": 1, + "metadata": {"primary": True}, }, # Keep the shipping fee in, even if it's 0 # so that we can upgrade/downgrade shipping prices in the future { "price_data": self.to_shipping_price_data(zone), "quantity": 1, + "metadata": {"shipping": True}, }, ] return line_items diff --git a/app/views.py b/app/views.py index 1acc0a5a..2e55804f 100644 --- a/app/views.py +++ b/app/views.py @@ -522,7 +522,7 @@ def create_checkout_context( "address": "auto", "name": "auto", }, - metadata={}, + metadata={"primary_product": product.id}, ) next = "/"