Updates a loyalty tier.
Use this endpoint to update tier-specific settings, such as the name and the required points
threshold of an individual loyalty tier. To update global settings that apply to all of a site's loyalty tiers,
use updateTiersProgramSettings()
.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateTier(_id: string, tier: UpdateTier): Promise<Tier>;
Tier ID.
Tier info to update.
import { tiers } from "wix-loyalty.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
/* Sample parameter values:
*
* {
* "tier": {
* "_id": "7e26e41b-3bb6-40c9-bb7e-855b9f4f69e2",
* "required_points": 80,
* "tierDefinition": {
* "name": "Updated Tier",
* "description": "Updated tier name"
* }
* }
* }
*/
const elevatedUpdateTier = elevate(tiers.updateTier);
export const updateTier = webMethod(Permissions.Anyone, async (_id, tier) => {
try {
const result = await elevatedUpdateTier(_id, tier);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
});
/* Promise resolves to:
* {
* "_createdDate": "2024-06-06T10:33:19.121Z",
* "_id": "7e26e41b-3bb6-40c9-bb7e-855b9f4f69e2",
* "_updatedDate": "2024-06-10T12:48:59.740Z",
* "requiredPoints": 80,
* "revision": "3",
* "tierDefinition": {
* "name": "Updated Tier",
* "description": "Updated tier name"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.