From 9b4fad4d974a826d7ec342aaa72982ca0e3622d9 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 11 Jul 2026 11:34:10 +0000 Subject: [PATCH 1/3] Changes Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com> --- src/lib/shopify.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib/shopify.ts b/src/lib/shopify.ts index 9bc0a98..9649385 100644 --- a/src/lib/shopify.ts +++ b/src/lib/shopify.ts @@ -43,6 +43,21 @@ export interface ShopifyProduct { }; }>; }; + sellingPlanGroups?: { + edges: Array<{ + node: { + name: string; + sellingPlans: { + edges: Array<{ + node: { + id: string; + name: string; + }; + }>; + }; + }; + }>; + }; options: Array<{ name: string; values: string[]; From 3596350425a0552a81b3ded32f389d31a06d7fe7 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 11 Jul 2026 11:34:15 +0000 Subject: [PATCH 2/3] Changes Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com> --- src/lib/shopify.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib/shopify.ts b/src/lib/shopify.ts index 9649385..dc63915 100644 --- a/src/lib/shopify.ts +++ b/src/lib/shopify.ts @@ -140,6 +140,21 @@ export const STOREFRONT_PRODUCTS_QUERY = ` } } } + sellingPlanGroups(first: 5) { + edges { + node { + name + sellingPlans(first: 10) { + edges { + node { + id + name + } + } + } + } + } + } options { name values From b8b7914eae537c93d4295f6f9f4dd92b08570baf Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 11 Jul 2026 11:34:23 +0000 Subject: [PATCH 3/3] Changes Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com> --- src/components/PlansSection.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/PlansSection.tsx b/src/components/PlansSection.tsx index c7d9967..d2d1b9b 100644 --- a/src/components/PlansSection.tsx +++ b/src/components/PlansSection.tsx @@ -54,11 +54,27 @@ const PlansSection = () => { return; } + const sellingPlanId = + shopifyProduct.node.sellingPlanGroups?.edges?.[0]?.node?.sellingPlans?.edges?.[0]?.node?.id; + + if (!sellingPlanId) { + toast.error( + "Ingen abonnemangsplan hittades i Shopify. Kontrollera att Appstle-planen är kopplad till produkten." + ); + return; + } + setLoadingMethod(method); try { const data = await storefrontApiRequest(CART_CREATE_MUTATION, { input: { - lines: [{ quantity: 1, merchandiseId: variant.id }], + lines: [ + { + quantity: 1, + merchandiseId: variant.id, + sellingPlanId, + }, + ], attributes: [ { key: "Antal anställda", value: String(employees) }, { key: "Rekommenderad mängd", value: `${recommendedKg} kg/vecka` },