How can i add a driver tip in magento onepage checkout process?

How can i add a driver tip in magento onepage checkout process?

October 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How can i add a driver tip in magento onepage checkout process?

Adding a Custom Driver Tip Step to Magento Onepage Checkout

As an experienced e-commerce developer, I understand how challenging it can be to modify the built-in checkout process in Magento platforms. In this guide, we’ll walk through the steps required to add a custom “Driver Tip” section between the shipping method and the payment information sections of your one-page checkout.

Steps to Implement the Driver Tip Checkout Step

  1. Create the Database Table for Tips

    • First, you need to create a new table in your Magento database that will store the available tip options.
    CREATE TABLE `mytips` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `tip_amount` decimal(9,2) NOT NULL DEFAULT '0.00',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB;
    
  2. Create the Model

    • Next, create a new model that extends Magento’s base model class.
    namespace MyCompany\MyModule\Model;
    
    class TipModel extends \Magento\Framework\Model\AbstractModel
    {
        protected $_eventPrefix = 'mytip';
    }
    
  3. Create the Resource Model

    • Create a resource model that inherits from the abstract Magento resource model.
    namespace MyCompany\MyModule\Model;
    
    class TipResource extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
    {
        protected $_eventPrefix = 'mytip';
    }
    
  4. Create the Tip Collection

    • Create a new collection that extends Magento’s base collection.
    namespace MyCompany\MyModule\Model;
    
    class TipCollection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
    {
        protected $_eventPrefix = 'mytip_collection';
    }
    
  5. Create the Checkout Step

    • Create a new file in app/code/MyCompany/MyModule/view/frontend/templates/onepage/tip.phtml.
    <div id="tip-step">
        <h2>Add Driver Tip</h2>
        <?php foreach ($tips as $tip): ?>
            <label><input type="radio" name="driver_tip" value="<?php echo $tip->getTipAmount() ?>"><?php echo '$' . $tip->getTipAmount() ?></label>
        <?php endforeach; ?>
    </div>
    
  6. Add the Step to Checkout

    • In your checkout configuration file (app/code/MyCompany/MyModule/view/frontend/js/onepage/checkout.js), add the following code:
    window.checkoutConfig.isGuestCheckoutAllowed = true;
    window.checkoutConfig.isCustomerCheckoutAllowed = true;
    
    window.checkoutConfig.tipStep = {
        'code': 'tip',
        'label': 'Add Driver Tip',
        'sort_order': 3 // Place it after the shipping method
    };
    
  7. Update Total Based on Tip

    • Modify your total price calculation code to include the selected tip.

Conclusion

By following these steps, you should now have successfully added a custom “Driver Tip” section to your Magento onepage checkout process. This allows customers to select from predefined tip amounts, which are then automatically included in their total payment amount.

Remember that this is a complex modification and may require additional tweaks depending on your specific configuration and requirements. If you encounter any issues or need further assistance, feel free to explore the Magento community forums and our own resources at LaravelCompany.com.

Checkout Database Extensions Errors

Our network