Search...
onProductCreated( )
An event that fires when a product is created.
Description
The onProductCreated()
event handler runs when a new product
is added to a store.
Note: Backend events don't work when previewing your site.
Syntax
function onProductCreated(event: ProductCreatedEvent): void
onProductCreated Parameters
NAME
TYPE
DESCRIPTION
event
ProductCreatedEvent
Information about the product that was created.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event when a product is created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.34export function wixStores_onProductCreated(event) {5 let productId = event._id;6}78/* Full event object:9 *10 * {11 * "_id": "5096485f-0239-3881-3f6a-63955708a4ec",12 * "name": "New Product",13 * "sku": "abc123",14 * "formattedDiscountedPrice": "$100.00",15 * "visible": true,16 * "mainMedia": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",17 * "price": 100,18 * "formattedPrice": "$100.00",19 * "discountedPrice": 100,20 * "pricePerUnit": 0.1,21 * "formattedPricePerUnit": "$0.10",22 * "mediaItems": [23 * {24 * "title": "Main Image",25 * "description": "Main Image",26 * "type": "IMAGE",27 * "src": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186"28 * }29 * ],30 * "currency": "USD",31 * "productPageUrl": "/product-page/new-product",32 * "ribbon": "New Arrival"33 * }34 *35 */