mitchellds Posted September 21, 2012 Share Posted September 21, 2012 V; CubeCart 5.1.4 with a couple of simple tweaks On my site at XebraParts.com, I offer a bunch of free, downloadable documents. So, here is the question: instead of the price for the free documents showing up as 0.00, is there a way for the price to show up as 'Free' ? Seems like a pretty simple and cool little tweak, yes? Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 22, 2012 Share Posted September 22, 2012 (edited) I can give you a simple hack to replace any 0.00 price in your store with the word "FREE" - note that you will be modifying a core file, so the tweak will not survive upgrades, it would have to be re-added after upgrading because the modified file will be overwritten. It would be better to write a little plugin using the hook system, but this may help you in the interim. Open up classes/catalogue.class.php, and find around line 803: To achieve the same effect in Latest Products section, edit yet another core file. Open up classes/cubecart.class.php, and find around line 113: $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); REPLACE that line with this code: //markscarts edited to replace 0.00 with text if ($product['price'] == "0.00") { $product['price'] = "FREE"; } else { //original line of code $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); } Two notes: 1) I use comments to indicate where I've added or changed code in the file, feel free to change comments, 2) The text "FREE" - I like to show it in all caps, but you can put any unadorned text there between the quote marks to achieve what you desire. OK - So this did not affect Latest Products! $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); REPLACE that line with this: // markscarts, edited to replace 0.00 with text if ($product['price'] == "0.00") { $product['price'] = "FREE"; } else { // original line of code: $product['price'] = $GLOBALS['tax']->priceFormat($product['price']); } And finally, a word on formatting . . . Note: You can use simple html tags (even proprietary ones as in my example) between the quote marks if you need to style your text, but do not use double quotation marks unless you escape them! example 1: $product['price'] = "<blink>FREE</blink>"; example 2: $product['price'] = "<span style="color: lime;">FREE</span>"; example 3: $product['price'] = "<span style='color: lime;'>FREE</span>"; Edited September 22, 2012 by markscarts Quote Link to comment Share on other sites More sharing options...
mitchellds Posted September 26, 2012 Author Share Posted September 26, 2012 Thank you very much for the information! I sincerely appreciate it! Quote Link to comment Share on other sites More sharing options...
markscarts Posted September 26, 2012 Share Posted September 26, 2012 You're welcome. I've added this info as a hack in the CC5 hacks & tweaks forum at www.cubecartforums.org Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.