How to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

How to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

Magento 2 is the most preferred CMS for developers owing to its customization capabilities. Today, I am giving one such customized solution to add custom field below apply discount code in Magento 2 cart page.

You can use this solution for multiple purposes and make the most out of the cart page when the customer is about to checkout.

At this step, the shopper has almost decided to convert and hence he/she is trusting your brand. Why not push them for more?

For instance, if you are offering a discount code, you can prompt them to click on a custom field below the discount code and ask to explore the detailed offer benefits or encourage them to avail a superior membership for more discounts.

Moreover, at this step, you can add a custom link that redirects them to check your best seller products. In this way, you can increase your average order value and boost sales.

Also, if you are offering product personalization, you can offer a custom button to start designing the product if they didn’t do it earlier. In this way, improve the shoppers’ store experience in Magento 2 store.

Lastly, if there’s any data you want from the customers that can be insightful data for your marketing strategy, use the below solution to add a custom textbox where they can enter the asked information!

Check this code if you want to implement any of the above scenarios or any other custom field based on your business requirements on the Magento 2 cart page.

Also, if you are looking to add a custom field on the checkout page in Magento 2, you can refer to my solution here.

Method to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

  1. Create registration.php file at app\code\Vendor\Module\registration.php

  2. Create module.xml file at app\code\Vendor\Module\etc directory

  3. Create checkout_cart_index.xml file at app\code\Vendor\Module\view\frontend\layout

  4. Create Custom.php file at Vendor\Module\Block\Cart

  5. Create custom.phtml file at Vendor\Module\view\frontend\templates\cart

Once implemented, you can see the custom field on the cart page in Magento 2 storefront as shown below:

How to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

That’s it.

If you have queries regarding this solution, feel free to ask in the Comments section below.

I would be happy to answer your question.

Do consider sharing this post with Magento Community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 9 Reviews)

Kanchi is a Magento Developer at Meetanshi. Apart from that, she is into dancing. In her free time, she likes to make handmade art and craft.

2 comments On How to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

  • Thanks a lot for your tutorials.
    In this one, once the customer proceeds to checkout, how is the custom field’s value saved in database? With controller or observer? Should we add a new column to table?

    • Hello Shadow,
      No, there’s no need to use a controller or observer.
      Create extension_attribute and add that column in quote related table.
      Thank You.

Leave a reply:

Your email address will not be published.