Categories: How To

How to Override “payment\methods.phtml” in Magento Custom Extension

In this digital era, people are more tending to shop online by making online payments. Even though there are various payment methods available online, but cash on delivery is still hot favorite & trustable payment method compared to other available methods. According to the survey, 70 % of buyers prefer to use cash on delivery to prevent their self from online transnational frauds. Understanding customer convenience and providing better service is must to be ahead in online E-commerce competition. But Everything doesn’t end up here, owning an E-commerce store; you always need to differentiate genuine and spam orders to deliver great user experience over the Internet.

During This festival season, one of our clients came up with requirement to identify genuine orders and remove spam COD orders from his E-commerce store by verifying customer. Previously, due to spam COD orders, he couldn’t locate customer on specified location and at the end of day, he need to pay shipping charges each and every time. To overcome this situation, he wanted to verify his customer mobile when a customer pick cash on delivery from available payment methods. To implement this scenario, we need to override payment\methods.phtml in custom Magento extension.

Go to app\design\frontend\Themes\Yourtheme\layout\extension.xml

<checkout_onepage_paymentmethod>
     <remove name="right"/>
     <remove name="left"/>
 
     <block type="checkout/onepage_payment_methods" name="root" output="toHtml" template="extension/methods.phtml">
         <action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
     </block>
    </checkout_onepage_paymentmethod>

Once you have added the above code, you need to add your own custom functionality code within methods.phtml file available at app\design\frontend\Themes\Yourtheme\extension\methods.phtml

You can use and customize above code to override any file on the checkout page as per your need. So, stay tuned to our Magento Blogs and let us know in the comment section if you faced any problem while implementing this code.
Don’t forgot to hit the stars if you like the blog and share it with other Magento users.
Happy Overriding!

Click to rate this post!
[Total: 11 Average: 4.3]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

2 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

5 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

5 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

5 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

6 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 week ago