Magento – Hide the price for a free product using jQuery

In the new version it was moved to the /catalog/product/view/type files. There is a separate file for each product type. Inside those file the line: getPriceHtml($_product) ?> is responsible for outputting the price.

But better yet, this tutorial I will show you how to write a simple jQuery script to change all “$0.00″ to “FREE”

First create a new javascript file and name it ds.js and insert the following code as follow.

jQuery(document).ready(function() {
	jQuery("span").each(function(i, e) {
		if ( (jQuery(e).attr('class') == "price") && (jQuery(e).text() == "$0.00") ) {
			jQuery(e).text("FREE");
		}
	})
})

Now create a folder name called js within your folder and save the following file under it. skin/frontend/default/YOURTHEME/js/ds.js

Simply open your page.xml which located
app/design/frontend/default/YOURTHEME/layout/page.xml
and add the following line

<action method="addItem"><type>skin_js</type><name>js/ds.js</name></action>

Be sure that your magento site had jQuery enable.

Related Posts Plugin for WordPress, Blogger...

I hope you have enjoyed this post, be sure to subscribe to my rss feed by click the subscribe button at the top.

Good Luck!

Be Sure to Subscribe to our feed or follow us on twitter to get the latest updates/patches
End of Article, Thanks for reading.
You can leave a response, or trackback from your own site.

6 Responses to “Magento – Hide the price for a free product using jQuery”

  1. adamhw says:

    Hi there

    I like your share here – however you say put <action method="addItem"><type>skin_js</type><name>js/ds.js</name></action> in app/design/frontend/default/YOURTHEME/layout/page.xml

    but my theme does not have such a folder – I can alter it in app/design/frontend/BASE/default/layout but there is no such directory as you specify in my installation – I'm using vers. 1.4

    I've tried adding it here but no luck

  2. balaraju says:

    hi there

  3. Well I truly enjoyed studying it. This information provided by you is very helpful for good planning.

  4. ola001 says:

    And how to place in the center of this side an element with width=900px?
    I try and it goes to the left… :(

  5. @oezoink_CB says:

    While this is a great fix for what I'm looking to do, my theme doesn't have page.xml – I do, on the other hand, have a local.xml in the folder you've specified… any help please?

  6. Seong says:

    It works good for English. But when doesn't work when i changed my language to Danish. I have tried that using Dkr 0,00 and 0,00 kr but seems not responding well. Any idea?

Leave a Reply