Magento – Setting default payment method and skip the payment step

checkoutmagento-1.9onestepcheckoutPHPtheme

I would like to 'skip' the payment method step on the one page checkout step in Magento.

I am currently using SagePay as my payment method and well, as SagePay is my only method it seems pretty pointless having the Payment Method step on the one page checkout.

How can I do this?

I guess I need to somehow set the SagePay option as the default, hide the payment method form the user and skip straight to the order review step?

Best Answer

One way to achieve this is in the file: app/design/frontend/base/default/template/checkout/onepage/payment/methods.phtml When looping over the selected methods add something like:

<?php if($_code == 'YOUR METHOD'): ?>
     <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
    <?php $oneMethod = $_code; ?>
<?php endif; ?>
    <label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>

Then add some JS at the bottom:

<script type="text/javascript">
//<![CDATA[
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
    <?php endif; ?>
//]]>

In reality this is all that default magento template is doing to help the user select only a single option if one is set via the admin. However what I think might be happening in your case is that you have 2 methods available even though one may not be visible as a option. Adding this to the template will select that option by default and move to next step.

Related Topic