Search.../

updateProductFields( )

Updates an existing product by ID.

Description

The updateProductFields() function returns a Promise that resolves when the product with the specified ID has been updated.

Only the properties passed in the Product object will be updated. All other properties will remain the same.

Note: Do not pass important information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change information, such as a buyer’s personal details (address, email, etc.) or product price information. To learn more about how to keep your code secure, see Security Considerations When Working with Wix Code.

Syntax

function updateProductFields(productId: string, productInfo: UpdateProductInfo): Promise<Product>

updateProductFields Parameters

NAME
TYPE
DESCRIPTION
productId
string

ID of the product to update.

productInfo
UpdateProductInfo

The information to update in the product.

Returns

Fulfilled - The updated product. Rejected - Error message.

Return Type:

Promise<Product>
NAME
TYPE
DESCRIPTION
_id
string

Product ID.

_updatedDate
string

Date product was last updated.

name
string

Product name.

description
string

Product description.

mainMedia
string

Main product media item URL (wix:image or https).

mediaItems
Array<MediaItem>

List of product media items.

sku
string

Product stock keeping unit value. Must be unique.

ribbons
Array<ProductRibbon>

Deprecated. Use ribbon instead.

currency
string

Product currency.

price
number

Product price. The price must be greater than its discount. The product price is propagated to the product's newly-created variants. Product variants whose prices have been updated directly are not affected by changes to the product price.

discountedPrice
number

Discounted product price.

formattedPrice
string

Product price formatted with the currency.

formattedDiscountedPrice
string

Discounted product price formatted with currency symbol.

inventoryItemId
string

ID for the inventory item.

discount
ProductDiscount

Product discount.

trackInventory
boolean

Indicates whether inventory is tracked for the product.

inStock
boolean

Indicates whether the product is in stock.

quantityInStock
number

Number of units currently in stock.

additionalInfoSections
Array<ProductAdditionalInfoSection>

Additional product information sections.

productOptions
ProductOptions

All the available options for a store product.

productPageUrl
string

Product page relative URL.

manageVariants
boolean

Indicates whether product variants are managed. Can be set to true only if the product has options. Once set to true, can be reset to false only if no variants exist. Use getProductVariants() to check if variants exist. You cannot set manageVariants to true if more than 300 variants are defined.

customTextFields
Array<ProductCustomTextFields>

List of product customization fields.

productType
string

Product type.

slug
string

Product slug.

weight
string

Product weight.

visible
boolean

Whether the product is visible to site visitors and appears in Content Manager collections.

variants
Array<VariantItem>

Product variants.

seoData
SeoData

Custom SEO data for the product. Learn more about SEO.

pricePerUnitData
pricePerUnitData

Details of the product's price per unit.

pricePerUnit
number

Price per unit.

formattedPricePerUnit
string

Price per unit formatted with currency symbol.

ribbon
string

Product ribbon. Used to highlight relevant information about a product. For example, "Sale", "New Arrival", "Sold Out".

brand
string

Product brand. Including a brand name can help improve your site’s visibility on search engines.

Was this helpful?

Update a product

Copy Code
1import wixStoresBackend from 'wix-stores-backend';
2
3wixStoresBackend.updateProductFields(productId, {
4 "name": "new name",
5 "price": "new price"
6})
7 .then((product) => {
8 // Product has been updated
9 const newProductName = product.name
10 const slug = product.slug
11 })
12 .catch((error) => {
13 // There was an error updating the product
14 console.error(error)
15 });