WooCommerce Checkout fields settings and customization hooks

白昼怎懂夜的黑 提交于 2020-12-23 06:10:55

问题


does anyone know where the original checkout field settings are, within the Woocommerce plugin files? E.g The original field labels and placeholders etc?


回答1:


There is no Checkout fields settings in Woocommerce…

But you can customize them using:
- The Woocommerce Developer Documentation reference to customize checkout fields
- or any of the availaible plugins which most of them are commercial.

1) Checkout fields are managed essentially by 3 Woocommerce classes:
- WC_Checkout Class using get_checkout_fields() method (and get_value() method)
- WC_Countries Class using get_default_address_fields() method and get_address_fields() method
- WC_Customer Class used also for My account Address fields.

And uses woocommerce_form_field() template function where the different field types are defined.

2) The main hooks involved in customizations are:
- woocommerce_default_address_fields filter hook and StackOverFlow related threads
- woocommerce_checkout_fields filter hook and StackOverFlow related threads
- woocommerce_billing_fields filter hook and StackOverFlow related threads
- woocommerce_shipping_fields filter hook and StackOverFlow related threads
- woocommerce_form_field_{$args\[type\]} filter hook and StackOverFlow related threads

3) The main related templates involved that can be overridden through via the theme are:
- checkout/form-checkout.php
- checkout/form-billing.php
- checkout/form-shipping.php
- checkout/form-loging.php

Related: Template structure & Overriding templates via a theme




回答2:


For Original Fields please visit on your "woocommerce/templates/checkout/form-billing.php"

Here you will see a function
//This below line of code is responsible to get the fields
$fields = $checkout->get_checkout_fields( 'billing' );

//this below code is resposnible to echo those fields/labels etc
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );

If you want to go in depth please visit woocommerce/includes/wc-template-fucntions.php "function woocommerce_form_field( $key, $args, $value = null )", check this.

Hope this may help you out!



来源:https://stackoverflow.com/questions/54421397/woocommerce-checkout-fields-settings-and-customization-hooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!