Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to replace buy now button


pcprinting

Recommended Posts

Posted

okay, after much searching thru the contributions and the forums, i thought perhaps the contri. for disabling the buy now button if the stock = 0 would work, but after installing it into my catalog with over 3,000 products, i realized it wouldnt work because they dont keep track of stock anyway!!! so here is the dilemma:

 

i have to replace the buy now button (or disable it) if the product is in a specific category. simple problem, why cant i find the solution?!??

 

any help is much appreciated! thanks everyone. :blush:

Posted

if I'm understanding you correctly you want to disable certain products to sell at different times?

Then you would go into your store Admin/Categories / Products and you have a little status button (toggle on/off)

Posted

I'm lost here.

 

I thought OSCommerce comes with options to tell the shop how many you have in stock. Once the Stock has depleated the item shows as 'Out of Stock' and the 'Buy It Now' button is removed.

 

Or I thought somewhere there was the option to change the item to Inactive once the stock was depleated?

 

Perhaps I'm wrong as I've not run out of stock yet...

I agree that could be a pretty bad problem if you have a very active store.

Posted

I'm very sorry, y'all are confused...

 

I simply want to use a NON-Linking button instead of the buy now button ONLY IN A SPECIFIC CATEGORY. I've gotten the feature to work in the catalog/product_info.php file because it was a simple "if" statement... I just can't figure out the part in the catalog/includes/modules/product_listing.php file. here it is below:

			break;
	  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've tried just taking out the <a href tags & using the same non-linking image as I did in product_info.php, but for some reason it breaks this way. If it helps, below are links to the problem pages on my site. If you are looking at our "Test Classified" on the product_info.php (click to view site) page, you will see the non-linking image instead of the "add to cart" button... I'm trying to pull this off when you are looking at the same product in this specific category on the index.php?cPath=23 page (click to view site) page because we dont want buy it now buttons. :huh:

Posted

I DID IT !!! I DID IT !!!

 

I finally said to myself, "self... why don't you just make the buy now button go to the product_info.php page that works..." friggin yeahhhhh.... if anyone needs to do disable the buy now button ONLY on a specific category, you only need to modify TWO files... here's the code you find/replace in the catalog/includes/modules/product_listing.php file:

 

//find this chunk toward the bottom:

		break;
	  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;

//replace with this code below:

		break;
	  case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'] . 

'&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . 

'</a> ';
		break;

 

THEN, NEXT STEP, IMPORTANT ONE...

in the catalog/product_info.php file find/replace this section of code below:

 

//find this section of code toward the bottom:

<?php
}
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<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>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
 }
?>
	</td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->


//replace with this code below:

<?php
}
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>

<!--Begin Custom Category If Statement, If Category is Classifieds, Display a Special Button-->

<?php

$cPath=$cPath;

if ($cPath==23)
{
?>

  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<td class="main" align="right"><img src="http://thehouseofdiesel.com/catalog/images/thod_button.jpg" border="0" alt="Please Call Us For Info or To Order This Product"></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr></table>
<?php

} else {
?>

<!--Do the Default Thing Below-->

  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			<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>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td>
<?php
}
?>

<!--End Custom Category If Statement-->

<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
 }
?>
	</td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->

  • 3 weeks later...
Posted
I'VE ADDED THE INSTRUCTIONS FOR THIS IN THE CONTRIBUTIONS, SEARCH FOR "DISABLE BUY NOW BUTTON"

Thanks for sharing...

I'm not familiar with php coding but I know I want to replace the buy now button with a sold out button the the stock of the product is zero.

The code modification that you did has nothing to do with whether the stock is 0 or not right? That code that you did just replaces the buy now button only without taking into account stock levels. Am I right?

Archived

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

×
×
  • Create New...