Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WooCommerce-免费产品的问题隐藏计费字段_Php_Css_Wordpress_Woocommerce_Checkout - Fatal编程技术网

Php WooCommerce-免费产品的问题隐藏计费字段

Php WooCommerce-免费产品的问题隐藏计费字段,php,css,wordpress,woocommerce,checkout,Php,Css,Wordpress,Woocommerce,Checkout,我试图隐藏免费产品的结帐(woocommerce)上的账单字段。我遇到了这段PHP代码,它似乎可以工作: function patricks_billing_fields( $fields ) { global $woocommerce; // if the total is more than 0 then we still need the fields if ( 0 != $woocommerce->cart->total ) { ret

我试图隐藏免费产品的结帐(woocommerce)上的账单字段。我遇到了这段PHP代码,它似乎可以工作:

function patricks_billing_fields( $fields ) {
    global $woocommerce;
    // if the total is more than 0 then we still need the fields
    if ( 0 != $woocommerce->cart->total ) {
        return $fields;
    }
    // return the regular billing fields if we need shipping fields
    if ( $woocommerce->cart->needs_shipping() ) {
        return $fields;
    }
    //we don't need the billing fields so empty all of them except the email
    unset( $fields['billing_country'] );
    unset( $fields['billing_last_name'] );
    unset( $fields['billing_company'] );
    unset( $fields['billing_address_1'] );
    unset( $fields['billing_address_2'] );
    unset( $fields['billing_city'] );
    unset( $fields['billing_state'] );
    unset( $fields['billing_postcode'] );
    unset( $fields['billing_phone'] );
    return $fields;
}
add_filter( 'woocommerce_billing_fields', 'patricks_billing_fields', 20 );
但是,当表单文本从字段中删除时,字段样式仍保留:

我用来设置表单字段(全局)样式的CSS是:

我已经检查了类似的线程,但似乎找不到答案

有人能给我指出正确的方向吗

谢谢

我已经测试了你的代码,我不明白这个问题。这当然与你的主题有关。此问题可能来自位于主主题或/和子主题的woocommerce文件夹中的自定义模板。它也可以是你主题的一些钩住的自定义函数。我已经测试了你的代码,我不明白这个问题。这当然与你的主题有关。此问题可能来自位于主主题或/和子主题的woocommerce文件夹中的自定义模板。它也可以是你的主题的一些钩住的自定义函数。
form .input-text {
       background: #f9f6f8;
       background: -webkit-gradient(linear,left top,left           bottom,from(#f9f6f8),to(#fff));
       background: -webkit-linear-gradient(#f9f6f8,#fff);
       background: -moz-linear-gradient(center top,#f9f6f8 0,#fff 100%);
       background: -moz-gradient(center top,#f9f6f8 0,#fff 100%);
       filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,  startColorstr=#f9f6f8, endColorstr=#ffffff);
       -ms-filter:  "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#f9f6f8,  endColorstr=#ffffff)";
       box-shadow: inset 0 1px 2px 0 rgba(0,0,0,.1);
       -webkit-box-shadow: inset 0 1px 2px 0 rgba(0,0,0,.1);
       -moz-box-shadow: inset 0 1px 2px 0 rgba(0,0,0,.1);
       -o-box-shadow: inset 0 1px 2px 0 rgba(0,0,0,.1);
       border: 1px solid #d7d4d6;
       outline: 0;
       line-height: 1em;
}