2015-08-24 20 views
5

Trường thanh toán-thanh toán của tôi và trường giao hàng được xuất bằng html với 3 sắp xếp hàng khác nhau. đầu tiên, cuối cùng và rộng. Tôi chỉ muốn đặt chúng là đầu tiên và cuối cùng - để mỗi đầu vào nằm cạnh nhau.Woocommerce: giúp thay thế đầu ra html

gốc:

<div class="woocommerce-billing-fields"> 

    <h3>Faktureringsdetaljer</h3> 




    <p class="form-row form-row form-row-first validate-required" id="billing_first_name_field"><label for="billing_first_name" class="">Fornavn <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_first_name" id="billing_first_name" placeholder="" value=""></p> 

    <p class="form-row form-row form-row-last validate-required" id="billing_last_name_field"><label for="billing_last_name" class="">Etternavn <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_last_name" id="billing_last_name" placeholder="" value=""></p><div class="clear"></div> 

    <p class="form-row form-row form-row-wide" id="billing_company_field"><label for="billing_company" class="">Navn på firma</label><input type="text" class="input-text " name="billing_company" id="billing_company" placeholder="" value=""></p> 

    <p class="form-row form-row form-row-wide address-field validate-required" id="billing_address_1_field"><label for="billing_address_1" class="">Adresse <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_address_1" id="billing_address_1" placeholder="Gateadresse" value=""></p> 

    <p class="form-row form-row form-row-last address-field validate-required validate-postcode" id="billing_postcode_field"><label for="billing_postcode" class="">Postnummer <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_postcode" id="billing_postcode" placeholder="Postnummer " value=""></p><div class="clear"></div> 

    <p class="form-row form-row form-row-wide address-field validate-required" id="billing_city_field"><label for="billing_city" class="">Sted <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_city" id="billing_city" placeholder="Sted" value=""></p> 

    <p class="form-row form-row form-row-first address-field validate-state" id="billing_state_field" style="display: none"><label for="billing_state" class="">Delstat/Fylke</label><input type="hidden" class="hidden" name="billing_state" id="billing_state" value="" placeholder=""></p> 

    <p class="form-row form-row form-row-first validate-required validate-email" id="billing_email_field"><label for="billing_email" class="">Epostadresse <abbr class="required" title="påkrevet">*</abbr></label><input type="email" class="input-text " name="billing_email" id="billing_email" placeholder="" value="[email protected]"></p> 

    <p class="form-row form-row form-row-last validate-required validate-phone" id="billing_phone_field"><label for="billing_phone" class="">Telefon <abbr class="required" title="påkrevet">*</abbr></label><input type="tel" class="input-text " name="billing_phone" id="billing_phone" placeholder="" value=""></p><div class="clear"></div> 


</div> 

Những gì tôi muốn:

<div class="woocommerce-billing-fields"> 

    <h3>Faktureringsdetaljer</h3> 




    <p class="form-row form-row form-row-first validate-required" id="billing_first_name_field"><label for="billing_first_name" class="">Fornavn <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_first_name" id="billing_first_name" placeholder="" value=""></p> 

    <p class="form-row form-row form-row-last validate-required" id="billing_last_name_field"><label for="billing_last_name" class="">Etternavn <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_last_name" id="billing_last_name" placeholder="" value=""></p> 

    <p class="form-row form-row form-row-first" id="billing_company_field"><label for="billing_company" class="">Navn på firma</label><input type="text" class="input-text " name="billing_company" id="billing_company" placeholder="" value=""></p> 

    <p class="form-row form-row form-row-last address-field validate-required" id="billing_address_1_field"><label for="billing_address_1" class="">Adresse <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_address_1" id="billing_address_1" placeholder="Gateadresse" value=""></p> 

    <p class="form-row form-row form-row-first address-field validate-required validate-postcode" id="billing_postcode_field"><label for="billing_postcode" class="">Postnummer <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_postcode" id="billing_postcode" placeholder="Postnummer " value=""></p> 

    <p class="form-row form-row form-row-last address-field validate-required" id="billing_city_field"><label for="billing_city" class="">Sted <abbr class="required" title="påkrevet">*</abbr></label><input type="text" class="input-text " name="billing_city" id="billing_city" placeholder="Sted" value=""></p> 

    <p class="form-row form-row form-row-first address-field validate-state" id="billing_state_field" style="display: none"><label for="billing_state" class="">Delstat/Fylke</label><input type="hidden" class="hidden" name="billing_state" id="billing_state" value="" placeholder=""></p> 

    <p class="form-row form-row form-row-first validate-required validate-email" id="billing_email_field"><label for="billing_email" class="">Epostadresse <abbr class="required" title="påkrevet">*</abbr></label><input type="email" class="input-text " name="billing_email" id="billing_email" placeholder="" value="[email protected]"></p> 

    <p class="form-row form-row form-row-last validate-required validate-phone" id="billing_phone_field"><label for="billing_phone" class="">Telefon <abbr class="required" title="påkrevet">*</abbr></label><input type="tel" class="input-text " name="billing_phone" id="billing_phone" placeholder="" value=""></p><div class="clear"></div> 


</div> 

Bất cứ ai biết nơi tôi có thể ghi đè lên những? Tôi đã tìm kiếm lên và xuống trong hầu hết các/bao gồm trong các thư mục woocommerce. không có một đầu mối.

Trả lời

4

Bạn có thể chỉ định chính xác những gì bạn muốn thay đổi không? Thật khó để so sánh và phát hiện sự khác biệt.

Nếu bạn chỉ muốn thay đổi các lớp học về một số lĩnh vực, đúng cách để làm điều đó là:

add_filter('woocommerce_checkout_fields' , 'custom_override_checkout_fields'); 

function custom_override_checkout_fields($fields) { 

    $fields['billing']['billing_company']['class'] = array('form-row', 'form-row', 'form-row-first'); 
    $fields['billing']['billing_address_1']['class'] = array('form-row', 'form-row', 'form-row-first', 'address-field', 'validate-required'); 
    $fields['billing']['billing_postcode']['class'] = array('form-row', 'form-row', 'form-row-first', 'address-field', 'validate-required'); 
    $fields['billing']['billing_city']['class'] = array('form-row', 'form-row', 'form-row-last', 'address-field', 'validate-required'); 
    $fields['billing']['billing_state']['class'] = array('form-row', 'form-row', 'form-row-first', 'address-field', 'validate-state'); 
    $fields['billing']['billing_email']['class'] = array('form-row', 'form-row', 'form-row-first', 'address-field', 'validate-email'); 
    $fields['billing']['billing_phone']['class'] = array('form-row', 'form-row', 'form-row-last', 'address-field', 'validate-phone'); 
    return $fields; 
} 

Bạn nên tuyệt đối không sử dụng JavaScript cho việc này.

+1

Cảm ơn @Pelmered - Chỉ cần những gì tôi cần. một trục trặc nhỏ là '

' cũng xuất ra ngay sau '['billing_postcode']'. Làm cách nào để xóa mục này? – user1769411

+1

À, chỉ cần thêm '$ trường ['thanh toán'] ['billing_postcode'] ['clear'] = ''' – Pelmered

+1

Để có thêm sửa đổi, chỉ cần var_dump trường '$' để có ý tưởng về những gì bạn nên thay đổi để có được những thay đổi mong muốn. Nó thực sự khá thẳng về phía trước khi bạn đọc đầu ra. – Pelmered

1

Thêm các lớp này có vẻ được chủ động thêm vào hoặc một plugin khó theo dõi tệp gốc vì nguyên nhân thêm các lớp này.

Để thay đổi các lớp bạn cần sử dụng jQuery làm phương sách cuối cùng. Và may mắn là có id cho mỗi trường để bạn có thể chọn các phần tử cụ thể và thay đổi thuộc tính của chúng.

Đây là mã có thể giúp bạn.

jQuery("#billing_company_field").removeClass("form-row-wide").addClass("form-row-first"); 

Mã trên sẽ thay đổi lớp chỉ cho một phần tử div. Sử dụng, Sửa đổi và thêm mã cần thiết khác. Mã này phải được đặt trên trang mà bạn cần thay đổi bị ảnh hưởng.

+0

Vâng, đây thực sự là phương sách cuối cùng. Nhưng trong trường hợp này, nó rất dễ dàng để thay đổi điều này một cách đúng đắn. – Pelmered

Các vấn đề liên quan