Php 移除';运输';Woocommerce中的签出字段错误

Php 移除';运输';Woocommerce中的签出字段错误,php,wordpress,woocommerce,field,checkout,Php,Wordpress,Woocommerce,Field,Checkout,我正在使用WooCommerce,并在结帐页面上启用了“发送到其他地址”部分。我想保留它,但我正在尝试删除几个字段。更具体地说,我正在尝试删除名、姓和州/省字段。我向子主题的functions.php文件中添加了以下代码: function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_first_name']); unset($fields['billing']['b

我正在使用WooCommerce,并在结帐页面上启用了“发送到其他地址”部分。我想保留它,但我正在尝试删除几个字段。更具体地说,我正在尝试删除名、姓和州/省字段。我向子主题的functions.php文件中添加了以下代码:

function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_first_name']);
    unset($fields['billing']['billing_last_name']);
    unset($fields['billing']['billing_state']);
    unset($fields[‘shipping’][‘shipping_first_name’]);
    unset($fields[‘shipping’][‘shipping_last_name’]);
    unset($fields[‘shipping’][‘shipping_state’]);
    return $fields;
}

当我使用此代码时,账单字段被删除,但当我打开“发送到其他地址”时,所有装运字段都会保留。不太清楚我在这里做什么不对,如果有任何帮助,我们将不胜感激。谢谢您的时间。

请检查,下面的代码中有语法错误。因为我认为WordPress不接受数组中的这些引号

unset($fields[‘shipping’][‘shipping_first_name’]);
unset($fields[‘shipping’][‘shipping_last_name’]);
unset($fields[‘shipping’][‘shipping_state’]);
请使用单引号,请使用下面的代码,然后进行测试

unset($fields['shipping']['shipping_first_name']);
unset($fields['shipping']['shipping_last_name']);
unset($fields['shipping']['shipping_state']);

您使用哪个钩子调用此方法?这是一个语法错误,感谢您的澄清!