估计是昨晚很晚了。答案很简单。以下来自我在原始问题中发布的链接。
/**
* Process the checkout
**/
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST['my_field_name'])
$woocommerce->add_error( __('Please enter something into this new shiny field.') );
}
所要做的就是:
if (!$_POST['my_field_name'])
$woocommerce->add_error( __('Please enter something into this new shiny field.') );
修改如下:
if (!($_POST['my_field_name'] || $_POST['my_checkbox']))
$woocommerce->add_error( __('Please enter something into this new shiny field or check the box.') );