2014-11-20 2 views
3

Я использую woocommerce_checkout_fields изменить ярлыки и fields.Below моего кодWooCommerce по умолчанию заполнителя не пошел в форме оформления заказа

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 меняются только при загрузке, то есть после загрузки страницы отображается указатель по умолчанию.

+0

Ваш код прекрасно работает на моем конце. –

+0

Если он отображается после загрузки страницы, он, вероятно, динамически изменяется с помощью JavaScript. – rnevius

+0

У меня такая же проблема. Есть идеи? – dominotrix

ответ

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'); 
0

Вы можете также изменить заполнителей по умолчанию:

add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields'); 
function custom_override_checkout_fields($fields) 
{ 
$fields['billing']['billing_company']['placeholder'] = 'Business Name'; 
return $fields; 
} 
Смежные вопросы