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
ID of the product to update.
The information to update in the product.
Returns
Fulfilled - The updated product. Rejected - Error message.
Return Type:
NAME
TYPE
DESCRIPTION
Product ID.
Date product was last updated.
Product name.
Product description.
Main product media item URL (wix:image or https).
List of product media items.
Product stock keeping unit value. Must be unique.
Deprecated. Use ribbon
instead.
Product currency.
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.
Discounted product price.
Product price formatted with the currency.
Discounted product price formatted with currency symbol.
ID for the inventory item.
Product discount.
Indicates whether inventory is tracked for the product.
Indicates whether the product is in stock.
Number of units currently in stock.
Additional product information sections.
All the available options for a store product.
Product page relative URL.
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.
List of product customization fields.
Product type.
Product slug.
Product weight.
Whether the product is visible to site visitors and appears in Content Manager collections.
Product variants.
Details of the product's price per unit.
Price per unit.
Price per unit formatted with currency symbol.
Product ribbon. Used to highlight relevant information about a product. For example, "Sale"
, "New Arrival"
, "Sold Out"
.
Product brand. Including a brand name can help improve your site’s visibility on search engines.
Was this helpful?
Update a product
1import wixStoresBackend from 'wix-stores-backend';23wixStoresBackend.updateProductFields(productId, {4 "name": "new name",5 "price": "new price"6})7 .then((product) => {8 // Product has been updated9 const newProductName = product.name10 const slug = product.slug11 })12 .catch((error) => {13 // There was an error updating the product14 console.error(error)15 });