Woocommerce默认占位符未以结帐形式出现

时间:2014-11-20 06:54:19

标签: php wordpress woocommerce

我正在使用woocommerce_checkout_fields更改标签和字段。我的代码是

function custom_override_checkout_fields($fields) {


     $fields['billing']['billing_first_name'] = array(
            'label' => '',
            'placeholder' => _x('First Name*', 'placeholder', 'woocommerce'),
            'required' => true,
            'class' => array('checkout-billing-first-name')
        );
        $fields['billing']['billing_last_name'] = array(
            'label' => '',
            'placeholder' => _x('last Name*', 'placeholder', 'woocommerce'),
            'required' => true,
            'class' => array('checkout-billing-last-name')
        );
        $fields['billing']['billing_company'] = array(
            'label' => '',
            'placeholder' => _x('Company Name', 'placeholder', 'woocommerce'),
            'required' => false,
            'class' => array('checkout-billing-company')
        );
        $fields['billing']['billing_address_1'] = array(
            'label' => '',
            'placeholder' => _x('Address(Line 1)*', 'placeholder', 'woocommerce'),
            'required' => true,
            'class' => array('checkout-billing-addressL1')
        );
         $fields['billing']['billing_address_2'] = array(
            'label' => '',
            'placeholder' => _x('Address(Line 2)*', 'placeholder', 'woocommerce'),
            'required' => false,
            'class' => array('checkout-billing-addressL2')
        );

        return $fields;
    }

    add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields');

一切正常但占用帐单地址1和帐单邮寄地址2的地方只会更改 在加载,即页面加载后,显示默认占位符。

2 个答案:

答案 0 :(得分:2)

尝试使用过滤器woocommerce_default_address_fields。

例如:

function pawelprotas_wc_default_address_fields($fields){
    $fields['address_1']['placeholder'] = __('Street address *', 'loft');
    $fields['address_2']['placeholder'] = __('Apartment, suite, unit etc.', 'loft');

    return $fields;
}

add_filter('woocommerce_default_address_fields', 'pawelprotas_wc_default_address_fields');

答案 1 :(得分:0)

您还可以更改默认占位符:

to_erl /tmp/erl_pipe