duanmie9682 2017-10-03 12:39 采纳率: 100%
浏览 22
已采纳

删除了仍然需要的Woocommerce Checkout字段

I'm removing specific Woocoomerce checkout fields, as they are not required for pick up orders.

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_1']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['billing']['billing_city']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_country']);
    unset($fields['billing']['billing_state']);
    unset($fields['order']['order_comments']);
    return $fields;
}

This works great to remove the fields but doesn't allow me to checkout. I receive the following error:

enter image description here

I've also tried to change the required array item to FALSE, to no avail.

$fields['billing']['billing_company']['required'] = false;
$fields['billing']['billing_address_1']['required'] = false;
$fields['billing']['billing_address_2']['required'] = false;
$fields['billing']['billing_city']['required'] = false;
$fields['billing']['billing_postcode']['required'] = false;
$fields['billing']['billing_country']['required'] = false;
$fields['billing']['billing_state']['required'] = false;

I'm using the Storefront theme as well as Woocommerce 3.1.2

  • 写回答

2条回答 默认 最新

  • dtp19819 2017-10-03 12:45
    关注

    It is an annoying thing in Woocommerce after version 3. Either downgrade to earlier version or allow those details through especially country. You can use css or JS to hide the form input but set the needed country in the woocommerce settings.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?