- 22, Oct 2024
- #1
У меня есть следующий код:
<tr>
<th><?php _e('Custom Stock Message'); ?></th>
<td>
<input type="text" name="customstock-msg" value=""/>
</td>
</tr>
<tr>
<th><?php _e('Order Processing Time'); ?></th>
<td>
<input type="text" name="customstock-Processing-time">
</td>
</tr>
<tr>
<th><?php _e('Instock Date'); ?></th>
<td>
<!-- <input type="date" name="customstock-date" value=""/>-->
<input type="text" id="datepicker" name="customstock-instockdate">
</td>
</tr>
<tr>
<th><?php _e('Show Quantity when Instock'); ?></th>
<td>
<!-- <input type="date" name="customstock-date" value=""/>-->
<select name="customstock-quantity" id="showquantity">
<option value="yes">Yes</option>
<option value="no"> No</option>
</select>
</td>
</tr>
<tr>
<th><?php _e('Show on Catlog Page'); ?></th>
<td>
<!-- <input type="date" name="customstock-date" value=""/>-->
<select name="customstock-catlogpage" id="showcatlogpage">
<option value="yes">Yes</option>
<option value="no"> No</option>
</select>
</td>
</tr>
?>
<p>
<input type="submit" class="button-primary" name="customstock_submit_specific_product" value="<?php _e('Save Changes') ?>" />
</p>
</form>
if(isset($_POST['customstock_submit_specific_product']))
{
global $wpdb,$product;
$id = $product->id;
$custommsg = sanitize_text_field( $_POST['customstock-msg'] );
$customprocessingtime = sanitize_text_field( $_POST['customstock-Processing-time'] );
$customstockquantity = sanitize_text_field( $_POST['customstock-quantity'] );
$customstockcatlogpage = sanitize_text_field( $_POST['customstock-catlogpage'] );
$customstockinstockdate = sanitize_text_field( $_POST['customstock-instockdate'] );
$customstockinstockdate = date("Y-m-d", strtotime($customstockinstockdate) );
$wpdb->insert('wp_woocommerce_specific_product_settings', array(
'custom_msg' => $custommsg,
'order_processing_time' => $customprocessingtime,
'exp_instock_date' => $customstockinstockdate,
'show_stockstatus_quantity' => $customstockquantity,
'showon_catlog' => $customstockcatlogpage,
'specific_product_id' => $id
));
}
Приведенный выше код выполняется при нажатии кнопки отправки.
Я не хочу хранить в wp_postmeta, что делать. Я новичок в WordPress. Кто-нибудь знает, как мне его сохранить?