@ahmdjsalhi here’s what the users see
And here’s the code for the calc function and the provided discount code:
$w('#button64').onClick((event,$w)=>{
if( $w('#input3').value === undefined){
// make what should be done.
total = 15
}
else{
wixData.query("DiscountCodes")
.eq('title', $w('#input3').value)
.eq('valid',true)
.find()
.then( (results) => {
if(results.length!==0){
//make what should be done.
total = 15
calc()
$w('#group9').hide();
$w('#text227').hide();
$w('#group8').show();
}
else{
// make a notice that this code is not available.
total = 0
calc()
$w('#group9').show();
$w('#text227').show();
$w('#group8').hide();
}
});
// the previous code. (checking the availability of the discount code in the collection.)
}
});
function calc() {
//You will spend a total of $42.00. This ad will run for 14 days ending on Jul 28, 2018.
price=0
price = pricew1 + pricew2 + pricew3 + pricew4 + pricew5 + pricew6 + pricew7 + pricew8 + pricew9 + pricew10 - total
console.log("(" + pricesize,') * ', till)
//$w('#calculate').html = `<span style='font-size: 16px', 'font-color: #FFFFFF'> $${price}.00</span> `
$w('#calculate1').html = `<span style="font-size: 14px">$${price}.00</span>`
var price1= "$" + price + ".00";
$w('#dataset2').setFieldValue('total',price1);
$w('#dataset2').setFieldValue('status',"Pending");
$w('#dataset2').setFieldValue('statusImage', "wix:image://red-circle-png_edited.png");
$w('#dataset2').setFieldValue('paymentStatus', "Not Received");
$w('#dataset2').setFieldValue('invoiceUpdate', "No invoice sent");
$w('#dataset2').setFieldValue('paymentStatusImage', "wix:image://red-circle-png_edited.png");
}
Also, I really appreciate your help here!! Thanks a lot.
I changed the total to 15, but would like the total to equal what is in the DB
@brettfranklin2 Actually, I didn’t understand the code that much and where the prices come from. but as I see there are two buttons. so maybe you need to separate them. the ‘apply’ button would check the discount code and the ‘place’ button would store what you want in database.
what I want to ask, what is working so far and what is not? is the cal() function makes what you want ?