我正在尝试在更新变量产品时向自定义表添加数据。
但是$_POST['_select22']
总是空的,我可以$_POST['post_title']
,但是无法获得$_POST['_select22']
,我也无法获得$_POST['product-type']
。
由于产品是变体产品,因此似乎无法使用。
我想知道如何获得$_POST['_select22']
更新/添加产品页面中的HTML代码:
<div class="options_group">
<p class="form-field _select_field "><label for="mgroup">mmy group</label>
<select id="mgroup" name="_select22" class="select short">
<option value="mc20">fit to pu2</option>
<option value="mc30">fit to pu3</option>
<option value="mc40">fit to pu4</option>
<option value="mc50">fit to pu5</option>
<option value="mc60">fit to pu6</option>
<option value="mc70">fit to pu7</option>
<option value="" selected="">Search Group</option>
</select>
</p>
</div>
function.php中的代码
// to add data to custom table when update product,
add_action('woocommerce_process_product_meta', 'woo_add_custom_general_fields_save');
function woo_add_custom_general_fields_save($post_id) {
global $wpdb;
if (!$_POST['_select22']) {
$all = $_POST['_select22'];
}
$table_filter = "cory_filter";
$data = array(
'id' => '',
'pid' => $post_id,
'cats' => 'semi-custom-seat-covers',
'mmy' => $all,
);
$wpdb - > insert($table_filter, $data);
}