繁体   English   中英

如何从 WooCommerce 结帐中清除特定的计费字段值

[英]How to clear specific billing field value from WooCommerce checkout

我正在尝试通过将以下代码添加到我的 functions.php 文件中,从我的 WooCommerce 结帐帐单中清除billing_po_no字段值:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    $fields['billing']['billing_po_no'] = '';

    return $fields;
}

但它似乎没有工作。 有人可以指出我正确的方向吗?

请尝试以下操作:

add_filter( 'woocommerce_checkout_get_value' , 'clear_specific_checkout_field' , 10, 2 );
function clear_specific_checkout_field( $value, $input ){
    if( $input === 'billing_po_no' )
        $value = '';
    
    return $value;
}

代码进入活动子主题(或活动主题)的functions.php文件。 它应该有效。

暂无
暂无

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

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