• Resolved gonzosgirrl

    (@gonzosgirrl)


    I added a field to my checkout page using eshop-extras and I am trying to remove the mandatory field from it. I tried removing this line from the php file:
    // Make additional checkout field mandatoryadd_filter('eshopCheckoutReqd','eshop_extras_required');function eshop_extras_required($values) { $values[] = 'eshop_extra'; return $values;}

    but that didn’t work. I also tried using the code from the wiki:

    // Remove zip/ post code from mandatory fields on checkout form.
    function my_mandatory_fields ($reqd) {
    	$new_reqd = array();
    	foreach( $reqd as $item ) {
    		if ( $item != 'zip') $new_reqd[] = $item;
    	}
    	return $new_reqd;
    }
    add_filter( 'eshopCheckoutReqd',  'my_mandatory_fields');

    to my functions file and changing ‘zip’ to ‘eshop_extra’ but that didn’t work either. Help?

    http://wordpress.org/extend/plugins/eshop/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Added fields are not mandatory by default.

    Thread Starter gonzosgirrl

    (@gonzosgirrl)

    I added the extra field using the eShop Extras plugin here http://quirm.net/wiki/eshop/additional-plugins-and-code-snippets/add-a-field-to-the-checkout/

    and I made it a telephone number. I didn’t change anything else from the sample but if I try to submit my form with that field blank it tells me it is a required field.

    There were some errors in the details you entered…
    
        Phone Number - missing.

    (It also has the red asterisk beside the field name which indicated ‘required’.)`

    Based on the original code for eshop-extras. try removing:

    // 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>';
    	}
    	return $myerror;
    }
    Thread Starter gonzosgirrl

    (@gonzosgirrl)

    That did the trick. Thank you!

    No problem 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: eShop] Mandatory field removal’ is closed to new replies.