hotfix(medusa-plugin-segment): Fix sku (#160)

This commit is contained in:
Oliver Windall Juhl
2021-02-01 11:56:34 +01:00
committed by GitHub
parent e974d3222e
commit 41eeecb5a8

View File

@@ -112,8 +112,13 @@ class SegmentService extends BaseService {
line_total
)
const skuParts = item.content.variant.sku.split("-")
skuParts.pop()
let sku = ""
if (item.variant.sku) {
let skuParts = item.variant.sku.split("-")
skuParts.pop()
sku = skuParts.join("-")
}
return {
name,
@@ -121,7 +126,7 @@ class SegmentService extends BaseService {
price: unit_price / 100,
reporting_revenue: revenue,
product_id: item.variant.product_id,
sku: item.variant.sku,
sku: sku,
quantity: item.quantity,
}
})