Happy New Year everyone!
I have a large number of users in a database on non-Wix site and have authorization to email them. I am importing the dB to Wix and want to be able to set subscriptionStatus in the Contacts collection, so my client can use the Wix tools for email marketing.
I am using Wix Studio to test how this works at the moment and am adding a Contact with this object:
This is my back end code - a self contained block that I trigger from the front end by calling the function. I pulled all this out of the API, except for the bit I’m struggling with.
console.log("running")
const item = {
name: {
first: "Gene",
last: "Lopez"
},
emails: [
{
tag: "WORK",
email: "gene.lopez@example.com"
},
{
tag: "HOME",
email: "gene.lopez.at.home@example.com",
primary: true
}
],
phones: [
{
tag: "HOME",
countryCode: "US",
phone: "(704)-454-1233"
},
{
tag: "MOBILE",
countryCode: "US",
phone: "(722)-138-3099",
primary: true
}
],
extendedFields: {
['emailSubscriptions.subscriptionStatus']: "subscribed"
},
labelKeys: [
"custom.member"
]
};
When I call this object to submit it using contacts.createContact(item, options), everything else goes into Contacts fine but I cannot figure out how to set the subscription setting…nothing I write to this field seems to stick - it shows NEVER SUBSCRIBED still. It doesn’t throw an error or anything, it just doesn’t get written to the contact.
Can anyone help point me in the right direction? I can’t see this in the API but it also doesn’t say it can’t be done. Surely I don’t have to go through every Contact in the collection setting these manually?..it’ll take forever! The alternative is to not set them and have the client use Mailchimp I guess…but that seems a little bit odd.
Simon.