I have code and set the value to hidden 0 or 1 on condition. Is there a better way to solve this?
<input type="hidden" name="type_product" value="" class="type_product"/>
<input type="hidden" name="type_category" value="" class="type_category" />
<input type="hidden" name="type_modifier" value="" class="type_modifier"/>
<input type="hidden" name="type_variant" value="" class="type_variant" />
<script>
$(function(){
let dataType = "product"; // category
if (dataType == "product") {
$(".type_product").val(1);
$(".type_category").val(0);
$(".type_modifier").val(1);
$(".type_variant").val(0);
}
if (dataType == "category") {
$(".type_category").val(1);
$(".type_product").val(0);
$(".type_modifier").val(0);
$(".type_variant").val(1);
}
})
</script>