enabled but dont want to show payment method on frontend checkout

if u wish to do like want to allowed some payment method work on backend but not in frontend. or may be like your payment method enabled
but it should not appear on frontend checkout.

for ex. in my case : i have one method "PAY By INVOICE". this will available in backend but not for frontend customers.

to accomplish this i modified in
path:- **/template/checkout/onepage/payment/methods.phtml

which contain the following.

<div class="payment-methods">
    <dl id="checkout-payment-method-load">
    <?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode() ?>
        <dt>
        <?php if( sizeof($this->getMethods()) > 1 ): ?>
            <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" class="radio" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> />
        <?php else: ?>
            <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" /></span>
        <?php endif; ?>
            <label for="p_method_<?php echo $_code ?>"><?php echo $_method->getTitle() ?></label>
        </dt>
        <?php if($html = $this->getChildHtml('payment.method.'.$_code)): ?>
        <dd>
            <?php echo $html; ?>
        </dd>
        <?php endif; ?>
    <?php endforeach; ?>
    </dl>
</div>
<script type="text/javascript">payment.init();</script>


here i substitute the $this->getMethods() array with my local one. which will actually hold the payment methods.
here i have to stop appering the "PaybyIvoicemethod".  i found out using firebug that the code for this method is
'paymentinvoice".
so here i make one array with this little bit code.

    $paymentmethod = array();
   
    foreach ($this->getMethods() as $method)
    {
        if($method->getCode()!='paymentinvoice')
        $paymentmethod[] = $method;
    }

    as u seen, here i put condition and change orriginal array and create new one.
after this you have to make one more change in original foreach loop and if statement. like following

foreach ($paymentmethod as $_method): $_code = $_method->getCode() ?>
        <dt>
        <?php if( sizeof($paymentmethod) > 1 ): ?>
        ....
        ...
       
now all things r ready. here payment method are enabled but not seen on frontend checkout..
hope this will help.

Comments

Popular posts from this blog

Magento Reindexing problem - take too long time

Magento Navigation menu of CMS pages

Script for to remove the cache - Magento