首先添加以下代码(可能还有WC Test Payment Gateway)并执行测试订单,以获取订单流程中通过woocommerce_after_checkout_validation 过滤器:
add_action(\'woocommerce_after_checkout_validation\',\'custom_modify_order\',10,1);
function custom_modify_order($posted) {
foreach ($posted as $key => $value) {$data .= $key.":".$value.PHP_EOL;}
$fh = fopen(get_stylesheet_directory().\'/orderdebug.txt\',\'w\');
fwrite($fh,$data); fclose($fh);
return $posted;
}
然后,当通过检查确定要转换的关键帧时
orderdebug.txt (在当前主题的根目录中输出),您可以删除前面的代码,并通过
woocommerce_process_checkout_field_* 过滤器:
// add the desired keys to this array in the following format, eg.
$uppercasefields = array(\'billing_first_name\',\'billing_last_name\');
foreach ($uppercasefields as $fieldkey) {
add_filter(\'woocommerce_process_checkout_field_\'.$fieldkey,\'custom_field_to_uppercase\');
}
function custom_field_to_uppercase($value) {return strtoupper($value);}
(参见功能
process_checkout 属于
woocoomerce/includes/class-wc-checkout.php 如果要查看此筛选器的应用位置)
EDIT: 这里似乎列出了钥匙:
https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
因此,您可能可以跳过第一步,但这仍然是一次有价值的调试体验。:-)