【发布时间】:2019-01-29 12:44:14
【问题描述】:
有谁知道 Woocommerce 插件文件中的原始结帐字段设置在哪里?例如原始字段标签和占位符等?
【问题讨论】:
标签: php wordpress woocommerce field checkout
有谁知道 Woocommerce 插件文件中的原始结帐字段设置在哪里?例如原始字段标签和占位符等?
【问题讨论】:
标签: php wordpress woocommerce field checkout
Woocommerce 中没有结帐字段设置...
但您可以自定义它们,使用:
- The Woocommerce Developer Documentation reference to customize checkout fields
- 或any of the availaible plugins,其中大部分是商业广告。
1) 结帐字段基本上由 3 个 Woocommerce 类管理:
- WC_Checkout 类使用get_checkout_fields() method (和get_value() 方法)
- WC_Countries 类使用 get_default_address_fields() method 和 get_address_fields() method
- WC_Customer 类也用于我的帐户地址字段。
并使用woocommerce_form_field() template function,其中定义了不同的字段类型。
2) 自定义涉及的主要钩子是:
- woocommerce_default_address_fields过滤钩和StackOverFlow related threads
- woocommerce_checkout_fields过滤钩和StackOverFlow related threads
- woocommerce_billing_fields过滤钩和StackOverFlow related threads
- woocommerce_shipping_fields过滤钩和StackOverFlow related threads
- woocommerce_form_field_{$args\[type\]} 过滤钩和StackOverFlow related threads
3) 涉及的主要相关模板 that can be overridden through via the theme有:
- checkout/form-checkout.php
- checkout/form-billing.php
- checkout/form-shipping.php
- checkout/form-loging.php
【讨论】:
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.
希望对你有所帮助!
【讨论】: