Setting the file. One moment.
Subchapter 2.89
references/stores/WRITE.mdMarkdown1 KBView on GitHub
if (v === 'V3_CATALOG') {
const product = await productsV3.createProduct({
name: 'My Product',
productType: 'PHYSICAL', // UPPER_CASE
variantsInfo: {
variants: [{
price: { actualPrice: { amount: '19.99' } }, // string, on the variant
sku: 'SKU-001',
}],
},
});
return product;
}
const { product } = await products.createProduct({
name: 'My Product',
productType: 'physical', // lower-case
priceData: { price: 19.99 }, // number, on the product
sku: 'SKU-001',
});
return product;if (v === 'V3_CATALOG') {
// Signature: updateProduct(_id, productFields). Returns Product directly.
const current = await productsV3.getProduct(id);
if (current.revision == null) throw new Error(`Product ${id} has no revision`);
return await productsV3.updateProduct(id, {
revision: current.revision, // narrowed — required under exactOptionalPropertyTypes
name: 'New name',
});
}
// V1: updateProduct(id, productFields). Returns { product }.
const { product } = await products.updateProduct(id, { name: 'New name' });
return product;if (v === 'V3_CATALOG') await productsV3.deleteProduct(id);
else await products.deleteProduct(id);