This is wordpress plugin code
function add_the_cart_limit( $countLimit ) {
woocommerce_admin_fields( set_limit() );
}
function set_limit() {
$args = array(
'status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
'limit' => -1,
);
$products_options = array();
$products = wc_get_products($args);
foreach ($products as $key => $product) {
$id = $product->id;
$products_options[$id] = $product->get_name();
}
$countLimit = array(
'chosen_product' => array(
'type' => 'select',
'multiple'=> true,
'id'=> 'chosen',
'required'=> true,
'name'=> __("Select a Product", 'your_text_domain'),
'options'=> $products_options
),
);
return $countLimit;
}
add_filter( 'woocommerce_settings_tabs_cartlimit', 'add_the_cart_limit', 10, 5 );
add_action( 'woocommerce_update_options_cartlimit', 'update_set' );
function update_set() {
woocommerce_update_options( set_limit() );
}
I inspect the code and it show <select name="chosen" id="chosen">...</select>
but i want <select multiple>
.
it does not select more than one option while holding ctrl key. Any help is appreciated...
I search it on goole and stackoverflow as well but did'nt find desire result. goole help me in the way that if i use simple html than it will work as
<select name="chosen" id="chosen" multiple="multiple">
<option value="1">A</option>
<option value="2">B</option>
</select>
but i don't want to use HTML format to make dropdown.
CodePudding user response:
i found the answer by my fellow developer. I use this line of code and it works for me
'custom_attributes'=> array('multiple'=> 'multiple'),