I have added custom text box field in my add product page in woocommerce. Now i want to make it required (compulsory). I tried it by passing argument "required"=>true. but it is not working. Please see below code
woocommerce_wp_text_input(
array(
'id' => 'special_price',
'label' => __( 'Wholesaler Price *', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'required' => 'true',
'description' => __( 'Enter wholesaler price here.', 'woocommerce' )
)
);
but it is not making textbox compulsory. Please can anyone tell how can i do this?
For the required
HTML5 attribute and other custom attributes woocommerce_wp_text_input()
function has custom_attributes
option.
woocommerce_wp_text_input(
array(
'id' => 'special_price',
'label' => __( 'Wholesaler Price *', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'custom_attributes' => array( 'required' => 'required' ),
'description' => __( 'Enter wholesaler price here.', 'woocommerce' )
)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With