如何在WooCommerce订单中添加订单交货日期和时间?

时间:2016-10-05 06:15:34

标签: php wordpress woocommerce

  

目前我正在开发用于下订单的REST API,我有   使用以下代码创建订单。

<?php
$order = wc_create_order(array('customer_id' => $user_id));

  $billing_addre = array(
        'first_name' => $_POST['f_name'],
        'last_name'  => $_POST['l_name'],
        'company'    => '',
        'email'      => $_POST['email'],
        'phone'      => $_POST['phone'],
        'address_1'  => $_POST['address'],
        'address_2'  => '', 
        'city'       => $_POST['city'],
        'state'      => $_POST['state'],
        'postcode'   => $_POST['p_code'],
        'country'    => $_POST['country']
    );

    $order->set_address( $billing_addre, 'billing' );

?>
  

它运作良好,但我想添加订单交付日期和时间   在创建订单期间,我使用自定义字段添加它,如

<?php
 update_post_meta( $order->id, 'delivery_date',  $_REQUEST["delivery_date"] );
?>
  

但这不是最佳方式,(我不会通过任何插件执行此操作)如果有人知道更好的解决方案。

     

谢谢!

0 个答案:

没有答案