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

Is it necessary to use pronouns with the verb "essere"?

Does the Linux kernel need a file system to run?

Is it allowed to activate the ability of multiple planeswalkers in a single turn?

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

Why is the "ls" command showing permissions of files in a FAT32 partition?

How to draw a matrix with arrows in limited space

What fields between the rationals and the reals allow a good notion of 2D distance?

Which Article Helped Get Rid of Technobabble in RPGs?

How does electrical safety system work on ISS?

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

Creating two special characters

Giving feedback to someone without sounding prejudiced

Taxes on Dividends in a Roth IRA

C++ check if statement can be evaluated constexpr

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

Mimic lecturing on blackboard, facing audience

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

Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?

Quoting Keynes in a lecture

Does the reader need to like the PoV character?

Has any country ever had 2 former presidents in jail simultaneously?

What is going on with gets(stdin) on the site coderbyte?

Is this toilet slogan correct usage of the English language?

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



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

How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її