使用自定义字段值填充WooCommerce订单备注

时间:2016-10-20 作者:Nienaber

我试图在Wordpress中使用自定义签出字段中的信息填充签出表单,以便将信息与订单一起保存并发送到电子邮件中。

add_action(\'woocommerce_checkout_process\', \'gfm_checkout_field_process\');

function gfm_checkout_field_process( $fields ) {

    // Validate pickup date if user chose to pickup the order

    if (WC()->session->get(\'chosen_shipping_methods\')[0] == \'local_pickup\') {
        $pickup_date = strtotime($_POST["gfm_pickup_date"]);

        $fields[\'order\'][\'order_comments\'] = $pickup_date;
    }
}
任何帮助都将不胜感激!

1 个回复
SO网友:Aarthna Maheshwari

Try this:

    add_filter( \'woocommerce_checkout_fields\', \'webendev_woocommerce_checkout_fields\' );
/**
 * Change Order Notes Placeholder Text - WooCommerce
 * 
 */
function webendev_woocommerce_checkout_fields( $fields ) {

    $fields[\'order\'][\'order_comments\'][\'placeholder\'] = \'Your custom placeholder\';
    return $fields;
}