WooCommerce 过滤器

WooCommerce filter

我已经将 WooCommerce 更新到最新的 3.3 版本。一切顺利,除了我有一个小问题,我似乎无法解决它。

在结帐页面,我创建了几个自定义输入字段。我还更改了某些字段的标签。所有修改都在 functions.php.

中完成

好的,我有一个字段 (billing_address_1) 并更改了该字段的标签,因此它被称为 "straat"(街道的荷兰语)。 这在 WooCommerce 3.0.0 中有效,但在 3.3 中无效。

这是我的代码:

add_filter( 'woocommerce_checkout_fields' , 
'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
 $fields['billing']['billing_address_1']['placeholder'] = '';
    if ( ICL_LANGUAGE_CODE == 'nl' ): {
        $fields['billing']['billing_address_1']['label'] = 'Adres';
    }
    elseif ( ICL_LANGUAGE_CODE == 'de' ): {
        $fields['billing']['billing_address_1']['label'] = 'Straßenname';
    }
    elseif ( ICL_LANGUAGE_CODE == 'fr' ): {
        $fields['billing']['billing_address_1']['label'] = 'Adresse';
    }
    elseif ( ICL_LANGUAGE_CODE == 'en' ): {
        $fields['billing']['billing_address_1']['label'] = 'Address';
    }
    elseif ( ICL_LANGUAGE_CODE == 'es' ): {
        $fields['billing']['billing_address_1']['label'] = 'Dirección';
    }
    endif;
 return $fields;
}

很长一段时间以来,这个过滤器在 Woo 3.3 中都没有改变,还是我遗漏了什么?

此致,

如果您阅读 documentation,您会发现您需要使用过滤器 woocommerce_default_address_fields 来更改某些特定字段。

在特定情况下,您需要使用 woocommerce_default_address_fields 过滤器。此过滤器适用于所有账单和运输默认字段: 国家,first_name , last_name , 公司 , address_1 , address_2 , 城市 , 状态 , 邮政编码