onProductCreated( )


An event that fires when a product is created.

The onProductCreated() event handler runs when a new product is added to a store.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
function onProductCreated(event: ProductCreatedEvent): void;
Method Parameters
eventProductCreatedEventRequired

Information about the product that was created.

An event when a product is created
JavaScript
// Place this code in the events.js file // of your site's Backend section. export function wixStores_onProductCreated(event) { let productId = event._id; } /* Full event object: * * { * "_id": "5096485f-0239-3881-3f6a-63955708a4ec", * "name": "New Product", * "sku": "abc123", * "formattedDiscountedPrice": "$100.00", * "visible": true, * "mainMedia": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186", * "price": 100, * "formattedPrice": "$100.00", * "discountedPrice": 100, * "pricePerUnit": 0.1, * "formattedPricePerUnit": "$0.10", * "mediaItems": [ * { * "title": "Main Image", * "description": "Main Image", * "type": "IMAGE", * "src": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186" * } * ], * "currency": "USD", * "productPageUrl": "/product-page/new-product", * "ribbon": "New Arrival" * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?