使用WooCommerce插件,我正在为每个可用属性创建一个复选框。我的问题是,当选择多个复选框时,只有一个选择被推入数据库。我的代码如下......
function faceted_search_init_fn(){
// set database functions class
global $wpdb;
$attribute_values = $wpdb->get_results("SELECT slug FROM wp_terms INNER JOIN wp_term_taxonomy INNER JOIN wp_woocommerce_attribute_taxonomies WHERE SUBSTR(wp_term_taxonomy.taxonomy, 4) = wp_woocommerce_attribute_taxonomies.attribute_name AND wp_term_taxonomy.term_id = wp_terms.term_id", ARRAY_A);
register_setting('faceted_options', 'faceted_options' );
add_settings_section('main_section', 'Main Settings', 'section_text_fn', __FILE__);
add_settings_field('plugin_chk', 'My Checkbox', 'setting_chk_fn', __FILE__, 'main_section', $attribute_values);
}
function setting_chk_fn($attribute_values) {
foreach($attribute_values as $attribute_value) {
echo $attribute_value['slug'];
echo "<input id='plugin_chk' name='faceted_options[noindex]' type='checkbox' value='" . $attribute_value['slug'] . "' />";
}
}
我很欣赏任何见解。