Jump to content

Resolved - Free Documents


mitchellds

Recommended Posts

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?

Link to comment
Share on other sites

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:

:glare: 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 . . . :sourcerer:

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 by markscarts
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...