【发布时间】:2018-11-28 18:00:11
【问题描述】:
请帮我解决这个问题..我尝试了太多不同的东西... 我正在尝试使用数据库中的数据填充 woocommerce 选择字段。
// Add fields & settings to the custom product tab
$SQL = "SELECT DISTINCT table_name FROM wp_lbc_prices";
$array = $wpdb->get_results( $SQL, ARRAY_A);
add_action( 'woocommerce_product_data_panels',
'wcpt_roller_blind_options_product_tab_content' );
function wcpt_roller_blind_options_product_tab_content() {
?><div id='roller_blind_options' class='panel woocommerce_options_panel'><?php
?><div class='options_group'><?php
woocommerce_wp_select( array(
'id' => 'roller_blind_tables',
'label' => __( 'Price Tables', 'wcpt' ),
'placeholder' => '',
'desc_tip' => 'true',
'description' => __( 'Select Associated Price Table.', 'wcpt' ),
'options' => $array
));
?></div>
</div><?php
当然,对数据库的查询有效并且正在返回结果......但我不确定如何制作一个可接受的数组(我习惯了 asp.net,这似乎使这更简单!) .我返回的数据不需要 ID,因此下拉列表的值和文本可以相同。
【问题讨论】:
标签: mysql wordpress select woocommerce