Kopplade Appstle till Shopify
X-Lovable-Edit-ID: edt-0ba318c7-392d-41ed-8b73-d220473b3207 Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com>
This commit is contained in:
@@ -54,11 +54,27 @@ const PlansSection = () => {
|
|||||||
return;
|
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);
|
setLoadingMethod(method);
|
||||||
try {
|
try {
|
||||||
const data = await storefrontApiRequest(CART_CREATE_MUTATION, {
|
const data = await storefrontApiRequest(CART_CREATE_MUTATION, {
|
||||||
input: {
|
input: {
|
||||||
lines: [{ quantity: 1, merchandiseId: variant.id }],
|
lines: [
|
||||||
|
{
|
||||||
|
quantity: 1,
|
||||||
|
merchandiseId: variant.id,
|
||||||
|
sellingPlanId,
|
||||||
|
},
|
||||||
|
],
|
||||||
attributes: [
|
attributes: [
|
||||||
{ key: "Antal anställda", value: String(employees) },
|
{ key: "Antal anställda", value: String(employees) },
|
||||||
{ key: "Rekommenderad mängd", value: `${recommendedKg} kg/vecka` },
|
{ key: "Rekommenderad mängd", value: `${recommendedKg} kg/vecka` },
|
||||||
|
|||||||
@@ -43,6 +43,21 @@ export interface ShopifyProduct {
|
|||||||
};
|
};
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
sellingPlanGroups?: {
|
||||||
|
edges: Array<{
|
||||||
|
node: {
|
||||||
|
name: string;
|
||||||
|
sellingPlans: {
|
||||||
|
edges: Array<{
|
||||||
|
node: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
options: Array<{
|
options: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
values: string[];
|
values: string[];
|
||||||
@@ -125,6 +140,21 @@ export const STOREFRONT_PRODUCTS_QUERY = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sellingPlanGroups(first: 5) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
name
|
||||||
|
sellingPlans(first: 10) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
options {
|
options {
|
||||||
name
|
name
|
||||||
values
|
values
|
||||||
|
|||||||
Reference in New Issue
Block a user