WooCommerce Checkout 字段设置和自定义挂钩

2021-12-22 00:00:00 field php wordpress woocommerce checkout

有谁知道 Woocommerce 插件文件中原始结账字段设置在哪里?例如原始字段标签和占位符等?

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

推荐答案

Woocommerce 中没有结帐字段设置...

但是您可以自定义它们:
- 用于自定义结帐的 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) 结帐字段主要由 ​​3 个 Woocommerce 类管理:
- WC_Checkout 使用 get_checkout_fields() 方法(和 get_value() 方法)
- WC_Countries 使用 get_default_address_fields() 方法和 get_address_fields() 方法
- WC_Customer 使用的类也适用于我的帐户地址字段.

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.

并使用 woocommerce_form_field() 模板函数,其中定义了不同的字段类型.

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

2) 自定义涉及的主要钩子是:
- woocommerce_default_address_fields 过滤器hook 和 StackOverFlow 相关线程
- woocommerce_checkout_fields 过滤器hook 和 StackOverFlow 相关线程
- woocommerce_billing_fields 过滤器hook 和 StackOverFlow 相关线程
- woocommerce_shipping_fields 过滤器hook 和 StackOverFlow 相关线程
- woocommerce_form_field_{$args[type]} 过滤钩子和StackOverFlow 相关线程

3) 涉及的主要相关模板 可以覆盖通过主题是:
- checkout/form-checkout.php
- checkout/form-b​​illing.php
- checkout/form-shipping.php
- checkout/form-loging.php

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

相关: 模板结构&通过主题覆盖模板

相关文章