feat: map prix marché as compare_at_price (barré) on Shopify

When Prix remisé is set: price = remisé, compare_at_price = marché
When no remise: price = marché, compare_at_price = null
Diff now detects compareAtPrice changes to trigger updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 14:19:37 +02:00
parent eb5f605175
commit 60dc9cc0ec
4 changed files with 12 additions and 5 deletions
+4 -1
View File
@@ -20,6 +20,7 @@ export function getConfig() {
interface ShopifyVariant {
id: number
price: string
compare_at_price: string | null
sku: string
inventory_quantity: number
}
@@ -42,6 +43,7 @@ function toSyncProduct(p: ShopifyAPIProduct): ShopifyProductFull {
title: p.title,
description: p.body_html ?? '',
price: p.variants[0]?.price ?? '0.00',
compareAtPrice: p.variants[0]?.compare_at_price ?? undefined,
stock: p.variants[0]?.inventory_quantity ?? 0,
status: p.status === 'active' ? 'active' : 'draft',
images: (p.images ?? []).map(i => i.src),
@@ -93,6 +95,7 @@ export async function createShopifyProduct(product: SyncProduct): Promise<string
const variant: Record<string, unknown> = {
price: product.price,
compare_at_price: product.compareAtPrice ?? null,
sku: product.ref,
inventory_management: 'shopify',
}
@@ -179,7 +182,7 @@ export async function updateShopifyProduct(
title: product.title,
body_html: product.description,
status: product.status,
variants: [{ id: variantId, price: product.price }],
variants: [{ id: variantId, price: product.price, compare_at_price: product.compareAtPrice ?? null }],
},
}