Hi,
I have the below mutation for productVariantsBulkCreate.
It is pretty much working except for the unitCost where I get the error that unitCost is not defined.
Does anyone know what might be causing this?
Mutation:
mutation CreateProductVariants($productId: ID!, $variantsInput: [ProductVariantsBulkInput!]!) {
productVariantsBulkCreate(productId: $productId, variants: $variantsInput) {
productVariants {
id
title
displayName
price
selectedOptions {
name
value
}
inventoryItem {
id
unitCost{
amount
currencyCode
}
sku
countryCodeOfOrigin
harmonizedSystemCode
tracked
measurement{
weight{
unit
value
}
}
requiresShipping
}
inventoryPolicy
inventoryQuantity
selectedOptions {
name
value
}
}
userErrors {
field
message
}
}
}
variables:
{
price: record.productPrice, // Variant price
optionValues: [ // Options for the variant (e.g., Size, Color)
{ name: size, optionName: "Size" },
{ name: color, optionName: "Color" },
],
inventoryItem: {
sku: `${record.productName} - ${color} - ${size}`,
tracked: trackQuantity,
requiresShipping: isPhysicalProduct,
harmonizedSystemCode: productData.hsCode,
countryCodeOfOrigin: productData.countryOfOriginCode,
unitCost:{
amount: cost,
currencyCode: currencyCode,
},
measurement:{
weight:{
unit: weightUnit,
value: weight,
},
},
},
inventoryPolicy: continueSelling ? "CONTINUE" : "DENY",
inventoryQuantities: [
{
availableQuantity: 100,
locationId: podifylocationID, // Location ID
},
],
};
Thanks in advance!
Bas
