I have created a file app/design/frontend/my_vendor/my_theme/Magento_Checkout/web/template/minicart/item/default.html
to write the Magento 2 standard mini cart default.html. And this is working fine.
However, I need to add some PHP code into my default.html. Can I change this to default.phtml, so I can add PHP code? and how do I tell the system to use default.phtml as the mini cart template? I can't find a layout.xml where we can define the file name.
Best Answer
Magento 2 using private content and KnockoutJs for load minicart.
Example add price row total to minicart.
Override DefaultItem customer data Magento\Checkout\CustomerData\DefaultItem
Add row total to doGetItemData function
Display on default template. Add snippet code below to default template (app/design/frontend/my_vendor/my_theme/Magento_Checkout/web/template/minicart/item/default.html)
Result: