Add JS to head in CartAdd Javascript File To Head For Create BlockPrepend block to Mage Head Block using controller_action_postdispatch event observerRewriting Html Head BlockAdd custom js in head in magento2?Adding New Facebook pixel to <head>Add google tag manager code inside head and bodyMagento2: How to add code inside the head tag?Add inline javascript to head - magento2I have magento 1.9.4 and running 3 stores and want to add a jv script from duda in the headAdd external stylesheet link-rel head tag

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

Does "he squandered his car on drink" sound natural?

Multiplicative persistence

Is there a RAID 0 Equivalent for RAM?

What to do when eye contact makes your coworker uncomfortable?

How much theory knowledge is actually used while playing?

Does the Linux kernel need a file system to run?

Mimic lecturing on blackboard, facing audience

How to convince somebody that he is fit for something else, but not this job?

Which Article Helped Get Rid of Technobabble in RPGs?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Why is the Sun approximated as a black body at ~ 5800 K?

Doesn't the system of the Supreme Court oppose justice?

Why is so much work done on numerical verification of the Riemann Hypothesis?

Make a Bowl of Alphabet Soup

What does Apple's new App Store requirement mean

What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?

Will number of steps recorded on FitBit/any fitness tracker add up distance in PokemonGo?

Non-trope happy ending?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

How to get directions in deep space?

Why do ¬, ∀ and ∃ have the same precedence?

Can I say "fingers" when referring to toes?

When were female captains banned from Starfleet?



Add JS to head in Cart


Add Javascript File To Head For Create BlockPrepend block to Mage Head Block using controller_action_postdispatch event observerRewriting Html Head BlockAdd custom js in head in magento2?Adding New Facebook pixel to <head>Add google tag manager code inside head and bodyMagento2: How to add code inside the head tag?Add inline javascript to head - magento2I have magento 1.9.4 and running 3 stores and want to add a jv script from duda in the headAdd external stylesheet link-rel head tag













0















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










share|improve this question














bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • did you try using core/template block?

    – Jaimin Sutariya
    Sep 24 '17 at 18:27











  • tried now, surprisingly still same...

    – RailBalco
    Sep 24 '17 at 19:13















0















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










share|improve this question














bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • did you try using core/template block?

    – Jaimin Sutariya
    Sep 24 '17 at 18:27











  • tried now, surprisingly still same...

    – RailBalco
    Sep 24 '17 at 19:13













0












0








0








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










share|improve this question














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







magento-1.9 javascript blocks head






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 24 '17 at 17:44









RailBalcoRailBalco

51




51





bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • did you try using core/template block?

    – Jaimin Sutariya
    Sep 24 '17 at 18:27











  • tried now, surprisingly still same...

    – RailBalco
    Sep 24 '17 at 19:13

















  • did you try using core/template block?

    – Jaimin Sutariya
    Sep 24 '17 at 18:27











  • tried now, surprisingly still same...

    – RailBalco
    Sep 24 '17 at 19:13
















did you try using core/template block?

– Jaimin Sutariya
Sep 24 '17 at 18:27





did you try using core/template block?

– Jaimin Sutariya
Sep 24 '17 at 18:27













tried now, surprisingly still same...

– RailBalco
Sep 24 '17 at 19:13





tried now, surprisingly still same...

– RailBalco
Sep 24 '17 at 19:13










1 Answer
1






active

oldest

votes


















0















  1. Go to app/design/frontend/package/theme/layout/local.xml then add this :



    <checkout_cart_index>
    <reference name="head">
    <action method="addItem"><type>skin_js</type><name>js/my-custom.js</name></action>
    </reference>
    </checkout_cart_index>


  2. Create your new js file in: skin/frontend/package/theme/js/my-custom.js then put your code inside.


  3. Now your js file will be just loaded in checkout/cart. Don't forget to clear the cache.



NB: I see some errors in your code:



1)



<frontend> // not </frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>


2)



You can't load this type of block in a head ! but you can do it content, root etc...



If you need is to add a js file, follow my solution.






share|improve this answer

























  • i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

    – RailBalco
    Sep 25 '17 at 8:01











  • What kind of block do you want to add ?, it's a Js file ?

    – PЯINCƏ
    Sep 25 '17 at 8:02











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194509%2fadd-js-to-head-in-cart%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0















  1. Go to app/design/frontend/package/theme/layout/local.xml then add this :



    <checkout_cart_index>
    <reference name="head">
    <action method="addItem"><type>skin_js</type><name>js/my-custom.js</name></action>
    </reference>
    </checkout_cart_index>


  2. Create your new js file in: skin/frontend/package/theme/js/my-custom.js then put your code inside.


  3. Now your js file will be just loaded in checkout/cart. Don't forget to clear the cache.



NB: I see some errors in your code:



1)



<frontend> // not </frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>


2)



You can't load this type of block in a head ! but you can do it content, root etc...



If you need is to add a js file, follow my solution.






share|improve this answer

























  • i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

    – RailBalco
    Sep 25 '17 at 8:01











  • What kind of block do you want to add ?, it's a Js file ?

    – PЯINCƏ
    Sep 25 '17 at 8:02
















0















  1. Go to app/design/frontend/package/theme/layout/local.xml then add this :



    <checkout_cart_index>
    <reference name="head">
    <action method="addItem"><type>skin_js</type><name>js/my-custom.js</name></action>
    </reference>
    </checkout_cart_index>


  2. Create your new js file in: skin/frontend/package/theme/js/my-custom.js then put your code inside.


  3. Now your js file will be just loaded in checkout/cart. Don't forget to clear the cache.



NB: I see some errors in your code:



1)



<frontend> // not </frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>


2)



You can't load this type of block in a head ! but you can do it content, root etc...



If you need is to add a js file, follow my solution.






share|improve this answer

























  • i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

    – RailBalco
    Sep 25 '17 at 8:01











  • What kind of block do you want to add ?, it's a Js file ?

    – PЯINCƏ
    Sep 25 '17 at 8:02














0












0








0








  1. Go to app/design/frontend/package/theme/layout/local.xml then add this :



    <checkout_cart_index>
    <reference name="head">
    <action method="addItem"><type>skin_js</type><name>js/my-custom.js</name></action>
    </reference>
    </checkout_cart_index>


  2. Create your new js file in: skin/frontend/package/theme/js/my-custom.js then put your code inside.


  3. Now your js file will be just loaded in checkout/cart. Don't forget to clear the cache.



NB: I see some errors in your code:



1)



<frontend> // not </frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>


2)



You can't load this type of block in a head ! but you can do it content, root etc...



If you need is to add a js file, follow my solution.






share|improve this answer
















  1. Go to app/design/frontend/package/theme/layout/local.xml then add this :



    <checkout_cart_index>
    <reference name="head">
    <action method="addItem"><type>skin_js</type><name>js/my-custom.js</name></action>
    </reference>
    </checkout_cart_index>


  2. Create your new js file in: skin/frontend/package/theme/js/my-custom.js then put your code inside.


  3. Now your js file will be just loaded in checkout/cart. Don't forget to clear the cache.



NB: I see some errors in your code:



1)



<frontend> // not </frontend>
<layout>
<updates>
<module_name>
<file>module_name.xml</file>
</module_name>
</updates>
</layout>
</frontend>


2)



You can't load this type of block in a head ! but you can do it content, root etc...



If you need is to add a js file, follow my solution.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 24 '17 at 20:49

























answered Sep 24 '17 at 20:23









PЯINCƏPЯINCƏ

8,34631143




8,34631143












  • i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

    – RailBalco
    Sep 25 '17 at 8:01











  • What kind of block do you want to add ?, it's a Js file ?

    – PЯINCƏ
    Sep 25 '17 at 8:02


















  • i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

    – RailBalco
    Sep 25 '17 at 8:01











  • What kind of block do you want to add ?, it's a Js file ?

    – PЯINCƏ
    Sep 25 '17 at 8:02

















i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

– RailBalco
Sep 25 '17 at 8:01





i tried changing from head to content or root, but still doesnt work. My main problem is that I cant use theme...

– RailBalco
Sep 25 '17 at 8:01













What kind of block do you want to add ?, it's a Js file ?

– PЯINCƏ
Sep 25 '17 at 8:02






What kind of block do you want to add ?, it's a Js file ?

– PЯINCƏ
Sep 25 '17 at 8:02


















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194509%2fadd-js-to-head-in-cart%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

Aasi (pallopeli) Navigointivalikko