I’m using wix-crm to sucessfully manage my contacts as they convert through various offers.
However, I can’t workout how I could remove a label.
For example, if a user triggers a specific event I offer them discount and apply the label “offer-xxabc”. If they redeem the offer, I apply the label “redeem-xxabc”. But I’d also like to remove the label “offer-xxabc” now that they’ve.
I know I can do this in the dashboard, but I’m trying to automate it.
really the only option until Wix changes its crm API is to NOT use CRM for this purpose.
The wix-crm api is a one way only api and I think is really focused on collecting mailing list users.
The best way to accomplish what you are trying to do is to manage your members in a data collection. There is a tutorial here:
I’m going to say before I start that I know this is an old topic, GOS, however I found it in a search looking for the information in the subject line. And later I found out that the ‘best answer’ is not correct, or not correct anymore.
So I wanted to add something for others who find this looking for the same information.
It is actually possible to remove a label from a contact. Here is a piece of backend code I wrote for adding and removing a label called ‘plan holders’. Additionally, it adds a label ‘cancelled plan holders’ when the ‘plan holders’ label is removed.
import wixCrmBackend from 'wix-crm-backend';
export async function addLabel (memberId) {
let contactInfo = await wixCrmBackend.getContactById(memberId)
let labels = contactInfo.labels
labels.push("Plan Holders")
return wixCrmBackend.updateContact(memberId, {labels:labels})
}
export async function removeLabel (memberId) {
let contactInfo = await wixCrmBackend.getContactById(memberId)
let labels = contactInfo.labels
labels = labels.filter(x => x !== "Plan Holders")
labels.push("Cancelled Plan Holders")
return wixCrmBackend.updateContact(memberId, {labels:labels})
}