// Add an additional field to the checkout within a new fieldset
add_filter('eshopaddtocheckout','eshop_extras_checkout');
function eshop_extras_checkout($echo){
$echo .= ' <script>
jQuery(function($) {
$(".formGroup").hide();
$("#chooseForm input:checkbox").on("change", function() {
if($(this).is(":checked")) {
$("#" + $(this).val()).show();
}
else {
$("#" + $(this).val()).hide();
}
});
});
</script>';
$echo .= '<fieldset class="eshop eshop_extra">' . "\n";
$echo .= '<legend>Select the Approriate Form</legend>' . "\n";
$echo .= ' <div id="chooseForm">
<input type="checkbox" name="forms2[]" id="ArticlesOrderForm" value="ArticlesOrderForm"> <b>Articles Order Form </b><br>
<input type="checkbox" name="forms2[]" id="PressReleasesForm" value="PressReleasesForm"> <b> Press Releases Form </b><br>
</div>
<div id="ArticlesOrderForm" class="formGroup">
<legend>Articles Order Form</legend>
<label for="kwd1">Art-Keywords1</label><input class="short" type="text" name="kwd1" value="" id="kwd1" maxlength="20" size="20" > <br>
</div>
<div id="PressReleasesForm" class="formGroup">
<legend>Press Releases Form</legend>
<label for="kwd2">PRKeywords2</label><input class="short" type="text" name="kwd2" value="" id="kwd2" maxlength="20" size="20"> <br>
</div>';
$echo .= '<fieldset class="eshop eshop_extra">' . "\n";
$echo .= '<legend>Extras</legend>' . "\n";
$echo .= '<label for="eshop_extra">'.__('Extra Field','eshop').' <span class="reqd">*</span><br />
<input class="short" type="text" name="eshop_extra" value="" id="eshop_extra" maxlength="20" size="20" /></label><br />';
$echo .= '</fieldset>' . "\n";
return $echo;
}
// Add extra field to error checks
add_filter('eshoperrorcheckout','eshop_extras_errorcheckout');
function eshop_extras_errorcheckout($_POST){
$myerror='';
if(!isset($_POST['eshop_extra']) || trim($_POST['eshop_extra'])==''){
$myerror= '<li>'.__('<strong>Extra Field</strong> - missing.','eshop_extras').'</li>';
}
if(!isset($_POST['ArticlesOrderForm'])) {
if(!isset($_POST['kwd1']) || trim($_POST['kwd1'])=='') {
$myerror= '<li>'.__('<strong>KWD1</strong> - missing.','kwd1').'</li>';
}
}
if(!isset($_POST['PressReleasesForm'])) {
if(!isset($_POST['kwd2']) || trim($_POST['kwd2'])=='') {
$myerror= '<li>'.__('<strong>KWD2</strong> - missing.','kwd2').'</li>';
}
}
return $myerror;
}
** 现在我没有收到任何语法错误....请检查下面的链接:(在选择适当的形式下),当您检查它们时,它们丢失了..我做错了什么..?**
articlewritingservicess.com/shopping-cart/checkout/