bulkUpdateProductProperty( )
Updates a property for up to 100 products at a time.
Description
The bulkUpdateProductProperty()
function returns a Promise that resolves when the
property of the products have been updated.
The properties that can be bulk-updated are detailed in the set
object in the parameters section below.
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.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - Bulk action results and metadata. Rejected - Error message.
NAME
TYPE
DESCRIPTION
Bulk action results.
Bulk action metadata.
Status/Error Codes
Was this helpful?
1/**************************************2 * Backend code - my-backend-file.jsw *3 **************************************/45import wixStoresBackend from 'wix-stores-backend';67export async function myBulkUpdateProductPropertyFunction(ids, set) {8 try {9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);10 console.log('Bulk action results:', productUpdateResults);11 return productUpdateResults;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 *************/2122import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';2324// Sample product IDs:25const ids = [26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",27 "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",28 "2966543c-2b2f-4ca1-862c-6a04736c1063",29 "c9adb138-96f8-4f08-8626-9fef2445c490",30 "4ed1aa2c-c441-4e3f-8e57-a18886bf52bb"31]3233// Set the price to 10.2534const set = {35 "price": 10.2536}3738myBulkUpdateProductPropertyFunction(ids, set)39 .then((productUpdateResults) => {40 console.log('Bulk action results:', productUpdateResults);41 return productUpdateResults;42 })43 .catch((error) => {44 console.error(error);45 // Handle the error46 });4748/* Promise resolves to:49 *50 * {51 * "results": [52 * {"itemMetadata": {53 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",54 * "originalIndex": 0,55 * "success": true56 * }},57 * {"itemMetadata": {58 * "id": "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",59 * "originalIndex": 1,60 * "success": true61 * }},62 * {"itemMetadata": {63 * "id": "2966543c-2b2f-4ca1-862c-6a04736c1063",64 * "originalIndex": 2,65 * "success": true66 * }},67 * {"itemMetadata": {68 * "id": "c9adb138-96f8-4f08-8626-9fef2445c490",69 * "originalIndex": 3,70 * "success": true71 * }},72 * {"itemMetadata": {73 * "id": "4ed1aa2c-c441-4e3f-8e57-a18886bf52bb",74 * "originalIndex": 4,75 * "success": true76 * }}77 * ],78 * "bulkActionMetadata": {79 * "totalSuccesses": 5,80 * "totalFailures": 0,81 * "undetailedFailures": 082 * }83 * }84 *85 */
1/**************************************2 * Backend code - my-backend-file.jsw *3 **************************************/45import wixStoresBackend from 'wix-stores-backend';67export async function myBulkUpdateProductPropertyFunction(ids, set) {8 try {9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);10 console.log('Bulk action results:', productUpdateResults);11 return productUpdateResults;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 *************/2122import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';2324// Sample product IDs:25const ids = [26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",27 "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",28 "2966543c-2b2f-4ca1-862c-6a04736c1063"29]3031// Set the ribbon to "On Sale"32const set = {33 "ribbon": "On Sale"34}3536myBulkUpdateProductPropertyFunction(ids, set)37 .then((productUpdateResults) => {38 console.log('Bulk action results:', productUpdateResults);39 return productUpdateResults;40 })41 .catch((error) => {42 console.error(error);43 // Handle the error44 });4546/* Promise resolves to:47 *48 * {49 * "results": [50 * {"itemMetadata": {51 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",52 * "originalIndex": 0,53 * "success": true54 * }},55 * {"itemMetadata": {56 * "id": "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",57 * "originalIndex": 1,58 * "success": true59 * }},60 * {"itemMetadata": {61 * "id": "2966543c-2b2f-4ca1-862c-6a04736c1063",62 * "originalIndex": 2,63 * "success": true64 * }}65 * ],66 * "bulkActionMetadata": {67 * "totalSuccesses": 3,68 * "totalFailures": 0,69 * "undetailedFailures": 070 * }71 * }72 *73 */
In this example, the second product ID is not found, so an error is returned for that update action.
1/**************************************2 * Backend code - my-backend-file.jsw *3 **************************************/45import wixStoresBackend from 'wix-stores-backend';67export async function myBulkUpdateProductPropertyFunction(ids, set) {8 try {9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);10 console.log('Bulk action results:', productUpdateResults);11 return productUpdateResults;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 *************/2122import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';2324// Sample product IDs:25const ids = [26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",27 "4deb9c8d-7aba-45e1-9d83-bf99b479b5bb"28]2930// Set the weight to 2.6431const set = {32 "weight": "2.64"33}3435myBulkUpdateProductPropertyFunction(ids, set)36 .then((productUpdateResults) => {37 console.log('Bulk action results:', productUpdateResults);38 return productUpdateResults;39 })40 .catch((error) => {41 console.error(error);42 // Handle the error43 });4445/* Promise resolves to:46 *47 * {48 * "results": [49 * {"itemMetadata": {50 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",51 * "originalIndex": 0,52 * "success": true53 * }},54 * {"itemMetadata": {55 * "id": "4deb9c8d-7aba-45e1-9d83-bf99b479b5bb",56 * "originalIndex": 1,57 * "success": false,58 * "error": {59 * "code": "PRODUCT_NOT_FOUND",60 * "description": "Product is not found"61 * }62 * }}63 * ],64 * "bulkActionMetadata": {65 * "totalSuccesses": 1,66 * "totalFailures": 1,67 * "undetailedFailures": 068 * }69 * }70 *71 */72