Messages can be displayed by using the MessageManager.
<?php
namespace Vendor\Module\Controller\Cart;
class Cart extends \Magento\Framework\App\Action\Action
{
protected $_messageManager;
public function __construct
(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager
)
{
$this->_messageManager = $messageManager;
parent::__construct($context);
}
public function execute()
{
$this->_messageManager->addSuccessMessage(__('Item Added to Cart Successfully.'));
$resultRedirect = $this->resultRedirectFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('checkout/cart');
}
}
You can use your custom module to overwrite the add to cart action/template and display a message with MessageManager.