I'm working on a new add-on to remove the Add to Cart button on the product_listing.php and the product_info.php for OsCommerce 2.3. This is because I want to be able to show our customers products we carry but do not have in stock but prevent them from adding them to their cart.
On product_info.php I got it working perfectly. For now the button is replaced with some text stating to use the contact form for more info. In a later stage I will change this to a neat button linking to the contact form and move the text to beneath the product image. Here's the code I have so far for product_info.php for who is interested :
<div class="buttonSet">
<?php
if ($product_info['products_quantity'] >=1) {
?>
<span class="buttonAction"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>
<?php
} else {
?>
<span class="OutOfStock"><?php echo TEXT_OUT_OF_STOCK_CONTACT; ?></span>
<?php
}
?>
So far no real challenges there. But when it comes to product_listing.php I've hit a snag. What I want to accomplish is that when a products stock hits 0, the Add to Cart button is replaced by a Out of stock button which when clicked will open the product info page. Here's the code so far :
case 'PRODUCT_LIST_BUY_NOW':
if ($listing['products_quantity'] == 0) {
$prod_list_contents .= ' <td align="center">' . tep_draw_button(IMAGE_BUTTON_OUT_OF_STOCK) . '</td>';
} else
if ($listing['products_quantity'] > 0) {
$prod_list_contents .= ' <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
}
break;
The thing is it replaces all the Add to cart (Buy now) buttons for the Out of stock button and seems to ignore the else statement. So I hope any of you guys wants to pitch in and can find the thing I'm overlooking. Any help is much appreciated.
Regards,
Emile



Find content
Male
