我找到了一种方法,可以手动将订单详细信息上的付款日期添加到WooCommerce的后台. 我已经在账单地址中创建了一个字段,我找到了一个日期拾取器的方法. 一切工作正常:我能够编辑帐单字段和打开日期 Select 器.
我的自定义代码:
// Edit Order details to add payment date
add_action( 'woocommerce_admin_order_data_after_billing_address', 'misha_editable_order_meta_billing' );
function misha_editable_order_meta_billing( $order ){
$billingdate = $order->get_meta( 'billingdate' );
?>
<div class="address">
<p<?php if( empty( $billingdate ) ) { echo ' class="none_set"'; } ?>>
<strong>Date deadline:</strong>
<?php echo ! empty( $billingdate ) ? $billingdate : 'Anytime.' ?>
</p>
</div>
<div class="edit_address">
<?php
woocommerce_wp_text_input( array(
'id' => 'paymentdate',
'label' => 'Date deadline',
'wrapper_class' => 'form-field-wide',
'class' => 'date-picker',
'style' => 'width:100%',
'value' => $billingdate,
'description' => 'Payment date.'
) );
?>
</div>
<?php
}
add_action( 'woocommerce_process_shop_order_meta', 'misha_save_general_details' );
function misha_save_general_details( $order_id ){
update_post_meta( $order_id, 'billingdate', wc_clean( $_POST[ 'billingdate' ] ) );
}
当我点击"更新"按钮时,我可以编辑这个字段,but I cannot save the field value.
有人能告诉我出什么事了吗?如何保存此字段值?