无法更改签出占位符文本

时间:2019-05-15 作者:cassiopeia

我在店面上使用woocommerce,在收银台上,地址1的占位符文本是“街道名称”,地址2是“公寓号”。

在我的国家,情况应该相反,或者在一个领域。

我试着用我在网上找到的代码片段来改变这一点。它们更改占位符,但仅在页面加载时的一瞬间更改占位符。之后,它们会更改回默认值

add_filter( \'woocommerce_checkout_fields\' \'override_billing_checkout_fields\', 10, 1 );

   function override_billing_checkout_fields( $fields ) {
       $fields[\'billing\'][\'billing_address_1\'][\'placeholder\'] = \'Address line 1\';
       $fields[\'billing\'][\'billing_address_2\'][\'placeholder\'] = \'Address line 2\';

       $fields[\'Shipping\'][\'shipping_address_1\'][\'placeholder\'] = \'Address line 1\';
       $fields[\'Shipping\'][\'shipping_address_2\'][\'placeholder\'] = \'Address line 2\'; 
       return $fields;
       }


   add_filter( \'woocommerce_default_address_fields\', \'uwc_new_address_one_placeholder\', 1 );

   function uwc_new_address_one_placeholder( $fields ) {
       $address_fields[\'address_1\'][\'placeholder\'] = \'Address line 1\';
       $address_fields[\'address_2\'][\'placeholder\'] = \'Address line 2\';
       return $address_fields;
       }   

1 个回复
SO网友:cassiopeia

我需要更改默认字段,但代码中有一个小错误。正确的代码是:

add_filter( \'woocommerce_default_address_fields\', \'uwc_new_address_one_placeholder\', 1 );

   function uwc_new_address_one_placeholder( $address_fields) {
       $address_fields[\'address_1\'][\'placeholder\'] = \'Address line 1\';
       $address_fields[\'address_2\'][\'placeholder\'] = \'Address line 2\';
       return $address_fields;
       }   
注意更改为$address_fields 在线3

相关推荐

如何让`wp-list-table`显示我在Custom-Post中的`Custom-Fields`

一切都好吗<我需要wp-list-table 也要显示custom-fields 在每个custom-post 我有,但我不知道如何做到这一点,在这幅图中,它显示了带有字段的表格:Title, Author and Publication Date: 我想要的是能够选择custom-fields 将出现,例如以下示例Title, Carta, Naipe, Author, and Date of Publication: