我使用 CSS 隐藏了变体框的标签,并向包含属性名称的选择框添加了自定义文本。这是我使用的代码:
function filter_woocommerce_dropdown_variation_attribute_options_args( $array ) {
$attribute_name = wc_attribute_label($array['attribute']);
$select_text = 'Choose an ' . $attribute_name;
$array['show_option_none'] = __( $select_text, 'woocommerce' );
return $array;
};
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'filter_woocommerce_dropdown_variation_attribute_options_args', 10, 1 );
隐藏标签的CSS:
.variations th.label {
display: none;
}
现在我只想让这句话变得可用,但我找不到合适的CSS。我几乎确定我需要使用 text-transform: capatilize
但我不确定在哪里添加它,最重要的是使用哪个 css class/id。我可以将其添加到代码片段中吗?
我在这里尝试了类似问题的一些答案,但它们都不起作用。
感谢任何帮助。
最佳答案
function filter_woocommerce_dropdown_variation_attribute_options_args( $array ) {
$attribute_name = wc_attribute_label($array['attribute']);
$select_text = ucwords( 'Choose an ' . $attribute_name );
$array['show_option_none'] = __( $select_text, 'woocommerce' );
return $array;
};
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'filter_woocommerce_dropdown_variation_attribute_options_args', 10, 1 );
请检查将字符串大小写更改为 upper 的链接, lower , capitalize ...
关于css - 将属性文本转换为在 WooCommerce 变体选择中大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74373565/