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条)

报告相同问题?

悬赏问题

  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要