Discount code fields

as a first step, think about the discount codes. You need to make a collection/table that has all the codes you have and the value of each one.
as a second step, you should be able to submit your form without trying to access the codes(the code input stills empty).

as, a third step, if the user wrote anything in the code input, you should check if this code existed in the database and make the discount if the discount code is active.

                        wixData.query("DiscountCodes") 
                        .eq('title', $w('#userInput').value) 
                        .eq('active', **true** ) 

                         .find() 
                         .then( (results) => { 

                          if (results.length!==0){ 
                                //make what should be done. 
                            } 

                         **else** { 
                            // make a notice that this code is not available. 

                         } 

});\

the previous code should be inside the onClick method for your button.

$w(“#submitButton”).onClick( (event, $w) => {
if( $w(’ #userInput ').value == undefined){
// make what should be done.
}

    else{ 
    // the previous code. (checking the availability of the discount code in the collection.) 
    } 

});

try these steps and I would help you more.
good luck!