Hello, I used to use a custom field in the debut theme; for some reason, on the Dawn theme, this code doesn’t add anything to the cart.
I have other custom fields that work perfectly. What might be the reason for that?
If you have any idea how to fix it, I would be grateful
<p class="line-item-property__field" style="margin-left: 5px; !important;">
<label>Do you want customization?</label>
<select id="custom" name="properties[Do you want customization?]">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</p>
<p class="line-item-property__field" id="customName" style="margin-left: 5px !important;">
<label for="NAME">Names:</label>
<input class="required" id="Customization" type="text" name="properties[Customization]">
</p>
<script>
const customField = document.querySelector('#custom');
const customName = document.querySelector('#customName');
const personalizacijaInput = document.querySelector('#Customization');
customName.style.display = "none";
personalizacijaInput.required = false;
customField.addEventListener('change', function() {
if (this.value == "Yes") {
customName.style.display = "block";
personalizacijaInput.required = true;
} else {
customName.style.display = "none";
personalizacijaInput.required = false;
personalizacijaInput.value = ''; // Clear the input value when not required
}
});
</script>