I have problem when I want to put JS into head when PHP condition is met, but I'm getting Mage_Core_Exception: Invalid block type excetion no idea why. I have read all the possible issues I have found but looks like there is ton of places I could go wrong and right now Im out of ideas.
I have config.xml where is my module declared. This is only part of it as rest of module is working, also JS and CSS I have in module_name.xml is working properly.
</frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>
Then I have module_name.xml I understand that I say here "on checkout/cart page load this template/modulename/prependca.phtml into of page.
<checkout_cart_index translate="label">
<reference name="head">
<block type="namespace_moduleName/cart" name="prependca" template="modulename/prependca.phtml"/>
</reference>
</checkout_cart_index>
Last, but not least, I have this Class of mine:
class Namespace_ModuleName_Block_Cart extends Mage_Checkout_Block_Cart_Abstract {
public function prependCa() {
$_quote = Mage::getSingleton('checkout/session')->getQuote();
if (get_class($_quote) == Mage_Sales_Model_Quote) {
$head = $this->getLayout()->getBlock('head');
$head->addJs('namespace/modulenameTotals.js');
$head->addItem('js', 'namespace/modulenameTotals.js');
}
}
}
From what I have read, I did all I had to do, however I still don't get results and only respond I get is Mage_Core_Exception: Invalid block type
core/template
block? – Jaimin Sutariya Sep 24 '17 at 18:27