Adjusts a numeric property for up to 100 products at a time.
The bulkAdjustProductProperty()
function returns a Promise that resolves when the
property of the products have been adjusted.
A property can be increased or decreased either by percentage or amount.
The properties that can be bulk-adjusted are detailed in the adjust
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.
function bulkAdjustProductProperty(
ids: Array<string>,
adjust: BulkAdjustProperties,
): Promise<BulkUpdateResponse>;
IDs of the products to adjust.
Numeric property to adjust.
/**************************************
* Backend code - my-backend-file.jsw *
**************************************/
import wixStoresBackend from "wix-stores-backend";
export async function myBulkAdjustProductPropertyFunction(ids, adjust) {
try {
const productAdjustmentResults =
await wixStoresBackend.bulkAdjustProductProperty(ids, adjust);
console.log("Bulk action results:", productAdjustmentResults);
return productAdjustmentResults;
} catch (error) {
console.error(error);
// Handle the error
}
}
/*************
* Page code *
*************/
import { myBulkAdjustProductPropertyFunction } from "backend/my-backend-file";
// Sample product IDs:
const ids = [
"91f7ac8b-2baa-289c-aa50-6d64764f35d3",
"0614129c-8777-9f3b-4dfe-b80a54df10d5",
];
// Increase the weight by 10
const adjust = {
weight: {
amount: 10,
},
};
myBulkAdjustProductPropertyFunction(ids, adjust)
.then((productAdjustmentResults) => {
console.log("Bulk action results:", productAdjustmentResults);
return productAdjustmentResults;
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* Promise resolves to:
*
* {
* "results": [
* {
* "itemMetadata": {
* "_id": "91f7ac8b-2baa-289c-aa50-6d64764f35d3",
* "originalIndex": 0,
* "success": true
* }
* },
* {
* "itemMetadata": {
* "_id": "0614129c-8777-9f3b-4dfe-b80a54df10d5",
* "originalIndex": 1,
* "success": true
* }
* }
* ],
* "bulkActionMetadata": {
* "totalSuccesses": 2,
* "totalFailures": 0,
* "undetailedFailures": 0
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.