大家好)我有一个 wp 代码(如下)。我需要为输入类型数字设置 min="1000" 和 max="10000" 。请告诉我需要在“'type' => 'number'”下面添加什么?谢谢!!!
add_action( 'woocommerce_before_add_to_cart_button', 'genius_product_price_input', 9 );
function genius_product_price_input() {
global $product;
if ( 100 !== $product->get_id() ) return;
woocommerce_form_field( 'set_price', array(
'type' => 'number',
'required' => true,
'placeholder' => 'Min. 1000, max. 10000',
'label' => 'Label text',
));
}
你可以试试这个:
add_action( 'woocommerce_before_add_to_cart_button', 'genius_product_price_input', 9 );
function genius_product_price_input() {
global $product;
if ( 100 !== $product->get_id() ) return;
woocommerce_form_field( 'set_price', array(
'type' => 'number',
'required' => true,
'placeholder' => 'Min. 1000, max. 10000',
'label' => 'Label text',
'custom_attributes' => ['min' => 1000, 'max' => 10000], // this is added
));
}
我基于文档:https://rudrastyh.com/woocommerce/woocommerce_form_field.html