Add is_required column to pp_shop_products_custom_fields table

This commit introduces a new column `is_required` to the `pp_shop_products_custom_fields` table. The column is of type TINYINT, cannot be null, and has a default value of 1. This change is intended to enhance the product custom fields by allowing the specification of whether a field is mandatory.
This commit is contained in:
2025-08-19 20:31:44 +02:00
parent 84333c1b59
commit ef15f16e18
16 changed files with 137 additions and 28 deletions

View File

@@ -1,10 +1,10 @@
<? if ( is_array( $this -> custom_fields ) ): foreach ( $this -> custom_fields as $custom_field ):?>
<div class="custom-field">
<div class="_name">
<?= $custom_field['name'];?>:
<?= $custom_field['name'];?><? if ( !empty( $custom_field['is_required'] ) ): ?>*<? endif; ?>:
</div>
<div class="_input">
<input type="text" class="form-control" name="custom_field[<?= $custom_field['id_additional_field'];?>]" field_name="<?= $custom_field['name'];?>" value="">
<input type="text" class="form-control" name="custom_field[<?= $custom_field['id_additional_field'];?>]" field_name="<?= $custom_field['name'];?>" value="" <? if ( !empty( $custom_field['is_required'] ) ): ?>required<? endif; ?>>
</div>
</div>
<? endforeach; endif;?>

View File

@@ -526,7 +526,7 @@
}
// dodatkowe pola muszą być uzupełnione
$( '.custom-field input' ).each( function( index, element )
$( '.custom-field input[required]' ).each( function( index, element )
{
if ( $.trim( $( element ).val() ) == '' )
{