Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Remove add to cart button for free items?


Guest

Recommended Posts

Is there a way to remove the ADD TO CART buttons ONLY for the free item category. My items are digital downloads and there is no need to login, create an account or to go through the payment process. I have the files stored on 4shared.com since I cant find a way to store them on the server for my site without having to go through the payment process. I have added a link for download, but it is in black and I need it blue and bold, I guess because people still click the add to cart button.

 

PLEASE someone give me some direction on how to do this. I dont want to have to take the page down.

 

thanks, michelle

Link to comment
Share on other sites

  • Replies 58
  • Created
  • Last Reply

This get's rid of the button, but you'll have an "open form" on the page.

 

And I'm not sure what the user will do to "continue".

 

I guess choose another category or hit the back button in the browser?

:unsure:

 

Without a lot of coding changes, I'm at a loss to suggest anything other than what you want - Remove the button.

 

Maybe someone sharper than me will come along with something better.

 

Until then, it won't be hard to give this a try...

 

MAKE A BACKUP OF THIS FILE BEFORE MAKING ANY EDITS.

 

In your /catalog/product_info.php find this code:

 

				<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

Change it to this:

 

<?php
 if ( $products_price >= 0.01 ) {
?>	  
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
<?php
 }
?>

Like I said, I'm not real happy with this, but I believe it will do what you want.

 

Or at least what you THINK you want...

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

OK.

 

I came up with a better idea (about 10 seconds after I posted).

 

Let's replace it with the "Back" button.

 

Find the same code as before, but replace it with the code below:

 

<?php
 if ( $products_price >= 0.01 ) {
?>	  
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
<?php
 } else {
?>
			<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $current_category_id ) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<?php
 }
?>

I like this, and I think you will too.

:)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

You're welcome, Ma'am.

:rolleyes:

 

From "cruising the forum" and looking at other posts, I thought you'd given up on the idea.

 

If you have problems with the code let me know.

 

I have a place where I can test it and "debug" it if necessary.

 

I would have done that the night I posted it, but it was late, I was tired, and I wanted to get the idea out there for you to consider.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

OK.

 

The code is posted won't work.

:blush:

 

I made a minor change:

 

<?php
 if ( $product_info['products_price'] >= 0.01 ) {
?>	  
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
<?php
 } else {
?>
			<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $current_category_id ) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<?php
 }
?>

This works.

 

I tried it out.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

  • 5 months later...
OK.

 

The code is posted won't work.

:blush:

 

I made a minor change:

 

<?php
 if ( $product_info['products_price'] >= 0.01 ) {
?>	  
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
<?php
 } else {
?>
			<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $current_category_id ) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<?php
 }
?>

This works.

 

I tried it out.

Could I use the above to hide the 'add to cart' button only when items are marked to $0 ?

 

I am trying to set up a site so that some items will be marked to $0 and offered as free downloads (using a simple link to the files that are free).

 

Thanks for any help,

zOnk

Link to comment
Share on other sites

Could I use the above to hide the 'add to cart' button only when items are marked to $0 ?

Yes.

:)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Yes.

:)

 

Hehehe.....cool. But...um....how? :D

 

I'm far from fluent in php...so if you could help...that'd be great.

 

thanks

 

***Edit***

 

Oh wait...you mean it'll already work as is? I just noticed the

if ( $product_info['products_price'] >= 0.01 )

 

Would I need to change that to "= 0.00" ?

Link to comment
Share on other sites

Hehehe.....cool. But...um....how? :D

 

I'm far from fluent in php...so if you could help...that'd be great.

 

thanks

 

***Edit***

 

Oh wait...you mean it'll already work as is? I just noticed the

if ( $product_info['products_price'] >= 0.01 )

 

Would I need to change that to "= 0.00" ?

If you want to show the add to cart if the product's price is greater than $0 then change it to > 0.

Link to comment
Share on other sites

I used .01 to avoid rounding errors.

 

If for whatever reason the price stored in the DB (as a STRING not a floating point number) came out an was evaluated to something wierdly small like .000001

 

Maybe a rare event, but dealing with floating point numbers and equalities can be tricky. I've done it.

 

That's why I chose >= .01 instead of >= 0

 

Use what you want.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Germ...thanks for the replies and help. I went with the .01 like you recommended, but I've got an issue.

 

It works if my products prices are set to $0 in the product page, but not if the product is on 'special' marked to $0. Meaning, it is $2.99 marked to Free ($0.00) on special.

 

Also, I noticed that the 'add to cart button only disapears (replaced with the 'back' button) when on the product 'details' page.

On any other pages (category list, etc.) the 'add to cart' button is still there.

 

Is there a way to get all items, whether on special or not to work with this? ..and to get the 'add to cart button' to be replace with 'back' on all pages?

 

 

Thanks again for the help :)

 

 

*I also tried rvsupply's suggestion, but it didn't work

Link to comment
Share on other sites

/catalog/includes/modules/product_listing.php

 

Old code:

 

		  case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {
		  $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
		} else {
		  $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
		}

New code:

 

		  case 'PRODUCT_LIST_PRICE':

		$free = false;

		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {

		  if ( $listing['specials_new_products_price'] < 0.01 ) $free = true;

		  $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
		} else {

		  if ( $listing['products_price'] < 0.01 ) $free = true;

		  $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
		}

Old code:

 

		  case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
		break;

New code:

 

		  case 'PRODUCT_LIST_BUY_NOW':
		if ( ! $free ) {
		  $lc_align = 'center';
		  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
		} else {
		  $lc_align = 'center';
		  $lc_text = ' ';
		}

Backup before making any edits.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Hmmm...this didn't seem to work for me.

 

Could it be that since I'm using a template it screwed it up? I'm guessing yes. My original code looks like this:

case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {
		$p_price =  $lc_text = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>   <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
		} else {
	   $p_price = $lc_text = '<span class="productSpecialPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
		}

 

and the second part that needed to be changed looks like this:

case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
		break;

 

I only noticed that the "$p_price = " was different from your code, so I tried adding it (after trying your code plain first) and I got: Parse error: syntax error, unexpected T_ELSE in /home/freenewt/public_html/oscfree/includes/modules/product_listing.php on line 238

 

Any suggestions?

 

*I really appreciate you taking time to help me with this :)

Link to comment
Share on other sites

case 'PRODUCT_LIST_PRICE':


  $free = false;

  $lc_align = 'right';
  if (tep_not_null($listing['specials_new_products_price'])) {

	if ( $listing['specials_new_products_price'] < 0.01 ) $free = true;

	$p_price =  $lc_text = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>   <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
  } else {

   if ( $listing['products_price'] < 0.01 ) $free = true;

   $p_price = $lc_text = '<span class="productSpecialPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
  }

 

case 'PRODUCT_LIST_BUY_NOW':
  if ( ! $free ) {
	$lc_align = 'center';
	$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
  } else {
	$lc_align = 'center';
	$lc_text = ' ';
  }
  break;

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Hmmm...still only works for products set up as price $0.00 and not for specials marked down to $0.00

 

:unsure:

 

*I'm gonna wait on the contribution to see if I can get this to work first. thx for the link tho

Link to comment
Share on other sites

It worked on my site.

 

The only part I coudn't check was the "special" price (no specials now).

 

So I haven't a clue.

:huh:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Hmmm...ok. Thanks for you help this far. I appreciate it.

 

It does work...but the specials are puttin up a fight for some reason. Other than that I am happy :D

 

@m_mcknight: Did you use the original code posted by Germ or the last one (which was meant for my specific themed version of OSC)?

 

If anyone else has an idea about why the Specials marked to $0 don't work and how to fix it...please post away

 

-z

Link to comment
Share on other sites

OK, so I put a product on "special" long enough to test my code and it works.

 

Have you double and triple checked that part of the code?

:unsure:

 

All I can say it works like it's supposed to for me...

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

You're very welcome Chell...

:rolleyes:

 

Nice to know my efforts weren't in vain.

:)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...