Hello everyone.
I want to add data to the collection I specified, but here is the error I get: insert Error: WDE0075: {“message”:“No coupon type”,“details”:{}}
Code:
console.log("HOŞGELDİN");
var sayi = 1;
while (sayi <= 100) {
//console.log(sayi);
var cupNY = "TOPLAM İNDİRİM: %" + String(sayi);
var cupCY = "HAZIR-Y-" + String(sayi)
let veri = {
name: cupNY,
startTime: String(new Date()),
expirationTime: null,
numberOfUsages: null,
limitedToOneItem: false,
expired: false,
percentOffRate: sayi,
limitPerCustomer: null,
scope: {
namespace: "stores"
},
displayData: null,
usageLimit: null,
minimumSubtotal: null,
code: cupCY,
appliesToSubscriptions: false,
type: "PercentOff",
appId: null,
active: true
};
//console.log("'veri' değişkeni:", veri);
veriler.push(veri);
console.log(veriler.length);
sayi = sayi + 1;
}
try {
wixData.insert("Marketing/Coupons", veriler[0])
.then((results) => {
console.log("İşlem başarılı:", results);
})
.catch((err) => {
console.error("insert", err); //the part where you get the error
});
} catch (error) {
console.log("HATA! KUPON OLUŞTURULAMADI:", error);
}
wixData.query("Marketing/Coupons")
.find()
.then(results => {
for (let index = 0; index < results.items.length; index++) {
console.log("Kupon:", results.items[index]);
}
})
At first I wanted to add bulk but it didn’t work, then I decided to try it with just one element (veriler[0]) but it failed.
I need your help.
Thank you.