To customize default Magento store functionality, you need to make changes in default Magento core function files. But, we have never recommended modifying default Magento core files instead of that follow these agile steps to override the core code using Custom Plugin in Magento 2.
Attachment 13584
for more tutorial: How to Override core code using Custom Plugin in Magento 2