简体   繁体   English

在结帐中取消设置自定义字段-woocommerce

[英]unsetting custom fields in checkout - woocommerce

I can unset fields from billing and shipping but why I can't unset fields from additional field section. 我可以取消帐单和运输的字段设置,但是为什么不能取消其他字段部分的设置。 I am adding a condition on these fields. 我在这些字段上添加了条件。 Maybe I am using wrong meta keys. 也许我使用了错误的元密钥。

function wc_remove_checkout_field( $fields ) {
    unset( $fields['billing']['test_field'] ); //this one working
    unset( $fields['additional']['delivery_time'] ); //this one not even if I replace additional with order.


    return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'wc_remove_checkout_field' );

Creating fields usings this plugin WooCommerce Checkout Field Editor 使用此插件创建字段WooCommerce Checkout字段编辑器

You can use this filter to remove the order notes field: 您可以使用此过滤器删除订单注释字段:

add_filter('woocommerce_enable_order_notes_field', '__return_false');

If you want to stick with your method using unset , you need to replace "additional" with "order": 如果您要坚持使用unset方法,则需要将“ additional”替换为“ order”:

unset($fields['order']['order_comments']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM