This might be a long shot. But I am attempting to create a product from my API. I am able to create a product but at a very basic since with one variation. I am hoping that someone might be able to show me a json payload creating/adding just about every property you can when creating items. I have the following code in place now
const catalogObject = {
idempotencyKey: `${newProduct.sku}-${Date.now()}`,
object: {
id: `#${newProduct.sku}`,
type: 'ITEM',
itemData: {
name: newProduct.name,
shortDescription: newProduct.shortDescription,
description: newProduct.description,
abbr: slugify(newProduct.name),
category: newProduct.category,
productType: 'REGULAR',
variations: [
{
id: `#${newProduct.sku}-variation`,
type: 'ITEM_VARIATION',
itemVariationData: {
itemId: `#${newProduct.sku}`,
name: `${newProduct.name} Variation`,
priceMoney: {
amount: Math.round(newProduct.price.value * 100),
currency: 'USD'
},
sku: newProduct.sku,
inventoryAlertType: 'LOW_QUANTITY',
inventoryAlertThreshold: 5,
pricingType: 'FIXED_PRICING'
}
}
]
}
},
customAttributeValues: {
'brand': newProduct.brand,
'price_unit': newProduct.price.unit,
'stock': newProduct.stock,
'weight': newProduct.weight ? `${newProduct.weight.value} ${newProduct.weight.unit}` : '',
'volume': newProduct.volume ? `${newProduct.volume.value} ${newProduct.volume.unit}` : '',
'dimensions': newProduct.dimensions ? `${newProduct.dimensions.length} x ${newProduct.dimensions.width} x ${newProduct.dimensions.height} ${newProduct.dimensions.unit}` : '',
'specifications': newProduct.specifications ? JSON.stringify(Object.fromEntries(Object.entries(newProduct.specifications))) : ''
}
};
While this code does create a product, it doesn’t seem to fully register all the properties and custom attributes I’m sending.
Could someone provide an example JSON payload/function that demonstrates how to include as many properties and custom attributes as possible when creating items through the Square API? I’d greatly appreciate a comprehensive example or any tips on what might be missing in my current setup.
Thank you!