Skipping Payment Methods in Magento EE Checkout Process
Magento provides robust e-commerce functionality, but sometimes clients have specific requirements that go beyond the default setup. One such requirement is skipping the payment method selection during the checkout process.
In this guide, we will walk through the steps to remove the payment method selection and enable customers to place orders without choosing a payment option in Magento EE 1.14.2.
Understanding the Checkout Process
The Magento checkout process consists of several stages, including shipping method, payment method, review, and submit order. By default, all these stages are mandatory for completing an order.
Removing Payment Method Selection
To skip the payment method selection during checkout, we need to perform two main tasks:
- Remove the payment method block from the checkout layout.
- Modify the order placement logic to create orders without a payment method.
Step 1: Modifying Checkout Layout
Open the checkout.xml file located at app/design/frontend/{package}/{theme}/layout/. If this file doesn’t exist, you can create it based on the default checkout.xml from the base theme.
Find the <reference name="checkout"> section and remove or comment out the following lines related to the payment method block:
<block type="core/text_list" name="checkout.payment.methods">
<action method="setTemplate">
<template>payment/form/ methods.phtml</template>
</action>
</block>
Save the changes and clear the Magento cache.
Step 2: Modifying Order Placement Logic
Next, we need to modify the order placement process to create an order without a payment method. Open the controllers/OnepageController.php file located at app/code/core/Mage/Checkout/controllers.
Find the saveOrderAction() method and make the following changes:
- Before the
$data->setPaymentMethod($paymentMethod)line, add this code to handle the case where no payment method is selected:
if (empty($paymentMethod)) {
$paymentMethod = 'free';
}
$data->setPaymentMethod($paymentMethod);
- In the same method, find the
$quote->collectTotals()->save();line and replace it with this code to prevent Magento from trying to collect totals for a payment method:
$quote->collectPrices();
$quote->save();
Save the changes and clear the Magento cache.
Conclusion
By following these steps, you have successfully modified your Magento EE 1.14.2 store to skip the payment method selection during checkout. Customers can now place orders without choosing a payment option.
Note: This modification should be done with caution, as it bypasses some core functionalities of Magento. Ensure that this approach aligns with your client’s specific requirements and business logic.
For more advanced customization options and best practices in Magento development, consider exploring the services offered by Laravel Company. Our experienced team specializes in Magento development, maintenance, and consulting to help you achieve your e-commerce goals effectively.