Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Prefer discount code attribution over click for new Shopify orders.

Kiran Kd36351af0f97
diff --git a/apps/web/lib/integrations/shopify/process-order.ts b/apps/web/lib/integrations/shopify/process-order.ts
index 43b7737313..d3059d17ef 100644
--- a/apps/web/lib/integrations/shopify/process-order.ts
+++ b/apps/web/lib/integrations/shopify/process-order.ts
@@ -69,32 +69,6 @@ export async function processShopifyOrder({
}
}
- // New customer
- if (clickId) {
- const { leadData } = await createShopifyLead({
- order,
- clickId,
- workspaceId: workspace.id,
- });
-
- const { saleData } = await createShopifySale({
- leadData,
- order,
- workspaceId: workspace.id,
- customerId: leadData.customer_id,
- });
-
- return {
- message: "Sale has been tracked for this order.",
- data: {
- ...sharedData,
- eventId: saleData.event_id,
- customerId: leadData.customer_id,
- attribution: "click",
- },
- };
- }
-
// Check if the order has created using a program discount code
if (discountCodes && discountCodes.length > 0 && workspace.defaultProgramId) {
const programDiscountCodes = await prisma.discountCode.findMany({
@@ -138,4 +112,30 @@ export async function processShopifyOrder({
};
}
}
+
+ // New customer
+ if (clickId) {
+ const { leadData } = await createShopifyLead({
+ order,
+ clickId,
+ workspaceId: workspace.id,
+ });
+
+ const { saleData } = await createShopifySale({
+ leadData,
+ order,
+ workspaceId: workspace.id,
+ customerId: leadData.customer_id,
+ });
+
+ return {
+ message: "Sale has been tracked for this order.",
+ data: {
+ ...sharedData,
+ eventId: saleData.event_id,
+ customerId: leadData.customer_id,
+ attribution: "click",
+ },
+ };
+ }
}