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

The IT department bottlenecks progress, how should I handle this?

How can I write humor as character trait?

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

Non-trope happy ending?

Delete multiple columns using awk or sed

How can ping know if my host is down

Stack Interview Code methods made from class Node and Smart Pointers

Permission on Database

Is there a RAID 0 Equivalent for RAM?

When were female captains banned from Starfleet?

How could a planet have erratic days?

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

Review your own paper in Mathematics

How do I tell my boss that I'm quitting soon, especially given that a colleague just left this week

How to draw a matrix with arrows in limited space

Is my low blitz game drawing rate at www.chess.com an indicator that I am weak in chess?

How much of a Devil Fruit must be consumed to gain the power?

A Trivial Diagnosis

Shouldn’t conservatives embrace universal basic income?

How does electrical safety system work on ISS?

Why does Carol not get rid of the Kree symbol on her suit when she changes its colours?

Mimic lecturing on blackboard, facing audience

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



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 3 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 3 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 3 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 3 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

六本木駅

Integral that is continuous and looks like it converges to a geometric seriesTesting if a geometric series converges by taking limit to infinitySummation of arithmetic-geometric series of higher orderGeometric series with polynomial exponentHow to Recognize a Geometric SeriesShowing an integral equality with series over the integersDiscontinuity of a series of continuous functionsReasons why a Series ConvergesSum of infinite geometric series with two terms in summationUsing geometric series for computing IntegralsLimit of geometric series sum when $r = 1$

Joseph Lister