I want to auto change the assigned group to business, if a customer enters the field "Company name" in the checkout.
I want to hide a payment method, if a customer enters the field "Company name" in the checkout.
This so that a payment method is not possible for business customers.
How can I achieve that?
Payment form:
<?php $this->setBlockData()?>
<?php $_code = $this->getMethodCode(); ?>
<?php $_helper = $this->helper('afterpay');?>
<?php $isEnterprise = (bool) Mage::getConfig()->getModuleConfig("Enterprise_Enterprise")->version;?>
<div id="payment-errors" class="validation-advice" style="display:none;"></div>
<fieldset class="form-list">
<ul id="payment_form_<?php echo $_code; ?>" style="display:none;">
<li>
<?php if($this->country == 'dede') : ?>
<div class="field">
<label for="<?php echo $_code; ?>_gender" class = "required"><em>*</em><?php echo $_helper->__('Gender:'); ?></label>
<div class="input-box" id="">
<input type="radio" name="payment[<?php echo $_code; ?>][gender]" value="M" id="<?php echo $_code?>_gender_m" checked="checked">
<label style="float:none" for="<?php echo $_code?>_gender_m"><?php echo $_helper->__('Male'); ?></label>
<input type="radio" name="payment[<?php echo $_code; ?>][gender]" value="V" id="<?php echo $_code?>_gender_v">
<label style="float:none" for="<?php echo $_code?>_gender_v"><?php echo $_helper->__('Female'); ?></label>
</div>
</div>
<?php else: ?>
<div class="field">
<label for="<?php echo $_code; ?>_gender" class = "required"><em>*</em><?php echo $_helper->__('Gender:'); ?></label>
<div class="input-box" id="">
<input type="radio" name="payment[<?php echo $_code; ?>][gender]" value="M" id="<?php echo $_code?>_gender_m" checked="checked">
<label style="float:none" for="<?php echo $_code?>_gender_m"><?php echo $_helper->__('Male'); ?></label>
<input type="radio" name="payment[<?php echo $_code; ?>][gender]" value="V" id="<?php echo $_code?>_gender_v">
<label style="float:none" for="<?php echo $_code?>_gender_v"><?php echo $_helper->__('Female'); ?></label>
</div>
</div>
<?php endif; ?>
<?php if ($isEnterprise): ?>
</li>
<li>
<?php endif;?>
<?php if (!$this->isB2B()): ?>
<div class="field">
<?php
echo $this->getLayout()->createBlock('afterpay/customer_widget_dob')
->setFieldIdFormat($_code . ':billing:%s')
->setFieldNameFormat('payment[' . $_code . '][%s]')
->setIsRequired(true)
->setPaymentMethodCode($_code)
->toHtml()
?>
</div>
</li>
<?php if ($this->showBankaccount()): ?>
<li>
<div class="field">
<label for="<?php echo $_code; ?>_bankaccount" class="required"><em>*</em><?php echo $_helper->__('Bank account number:'); ?></label>
<div class="input-box">
<input type="text" class = "required-entry" id="<?php echo $_code; ?>_bankaccount" name="payment[<?php echo $_code; ?>][bankaccount]" style="">
</div>
</div>
</li>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->isB2B()): ?>
<li>
<div class="field">
<label for="<?php echo $_code; ?>_companyname" class="required"><em>*</em><?php echo $_helper->__('Company name:'); ?></label>
<div class="input-box">
<input type="text" value="<?php echo $this->getCompany(); ?>" class="required-entry" id="<?php echo $_code; ?>_companyname" name="payment[<?php echo $_code; ?>][companyname]">
</div>
</div>
<div class="field">
<label for="<?php echo $_code; ?>_department" class=""><?php echo $_helper->__('Department:'); ?></label>
<div class="input-box">
<input type="text" class = "" id="<?php echo $_code; ?>_department" name="payment[<?php echo $_code; ?>][department]">
</div>
</div>
</li>
<li>
<div class="field">
<label for="<?php echo $_code; ?>_coc" class="required"><em>*</em><?php echo $_helper->__('Coc number:'); ?></label>
<div class="input-box">
<input type="text" class = "required-entry" id="<?php echo $_code; ?>_coc" name="payment[<?php echo $_code; ?>][coc]">
</div>
</div>
<div class="field">
<label for="<?php echo $_code; ?>_vat" class="required"><em>*</em><?php echo $_helper->__('Vatnumber:'); ?></label>
<div class="input-box">
<input type="text" class = "required-entry" id="<?php echo $_code; ?>_vat" name="payment[<?php echo $_code; ?>][vat]">
</div>
</div>
</li>
<li>
<div class="field">
<label for="<?php echo $_code; ?>_costcenter"><?php echo $_helper->__('Costcenter'); ?></label>
<div class="input-box">
<input type="text" id="<?php echo $_code; ?>_costcenter" name="payment[<?php echo $_code; ?>][costcenter]">
</div>
</div>
</li>
<?php endif; ?>
<button type="button" class="button" onclick="payment.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
<?php if (!$this->isAdvisoryprocess() && $this->country != 'dede'): ?>
<li class="accept-afterpay">
<input type="checkbox" class="required-entry" id="<?php echo $_code; ?>_termsAndConditions" name="payment[<?php echo $_code; ?>][conditions]" style="float:left;">
<label for="<?php echo $_code; ?>_termsAndConditions" class="required" style="padding-left:5px; float:left;">
<em>*</em>
<?php echo $_helper->__(
'Ik ga akkoord met de %sbetalingsvoorwaarden%s van AfterPay',
$this->paymentConditionsUrl,
$this->anchorClose
);?>
</label>
</li>
<?php elseif ($this->isAdvisoryprocess() && $this->country != 'dede'): ?>
<li class="accept-afterpay">
<input type="checkbox" class="required-entry" id="<?php echo $_code; ?>_termsAndConditions" name="payment[<?php echo $_code; ?>][conditions]" style="float:left;">
<label for="<?php echo $_code; ?>_termsAndConditions" class="required" style="padding-left:5px; float:left;">
<em>*</em>
<?php echo $_helper->__(
'Ik ga akkoord met de %sbetalingsvoorwaarden%s van Mijnbetaalplan',
$this->paymentConditionsUrl,
$this->anchorClose
);?>
</label>
</li>
<?php endif; ?>
</ul>
</fieldset>