删除 Woocommerce 中的 'shipping' 结帐字段错误
Removing 'shipping' checkout fields error in Woocommerce
我正在使用 WooCommerce 并在结帐页面上启用了 'Ship to a Different Address' 部分。我想把它留在那里,但我想删除几个字段。更具体地说,我正在尝试删除名字、姓氏和 state/province 字段。我将以下代码添加到我的子主题的 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;
}
当我使用此代码时,账单字段被删除,但当我打开时,所有发货字段都保留 'Ship to a different address'。不确定我在这里做错了什么,我们将不胜感激。谢谢你的时间。
请检查,以下代码中存在语法错误。因为我认为 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']);
我正在使用 WooCommerce 并在结帐页面上启用了 'Ship to a Different Address' 部分。我想把它留在那里,但我想删除几个字段。更具体地说,我正在尝试删除名字、姓氏和 state/province 字段。我将以下代码添加到我的子主题的 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;
}
当我使用此代码时,账单字段被删除,但当我打开时,所有发货字段都保留 'Ship to a different address'。不确定我在这里做错了什么,我们将不胜感激。谢谢你的时间。
请检查,以下代码中存在语法错误。因为我认为 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']);