Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

adding a soldout.gif if stock is 0? help needed


godino1

Recommended Posts

Trying to add an if statement to the below code in new_product.php so if out of stock then quantity box and button which i've added will not show but soldout.gif will. Any one can help me please? what to add and where?

 

 

$row = 0;

$col = 0;

$info_box_contents = array();

while ($new_products = tep_db_fetch_array($new_products_query)) {

$new_products['products_name'] = tep_get_products_name($new_products['products_id']);

$info_box_contents[$row][$col] = array('align' => 'center',

'params' => 'class="smallText" width="33%" valign="top"','text' =>

 

'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br>

<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>

<form name="cart_quantity" method="post" action="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'). '"><input type="hidden" name="products_id" value="' . $new_products['products_id'] . '"><input type="text" name="quantity" value="1" maxlength="5" size="5"><br>' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form><br>

<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '"><br>' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif') . '</a><br>' .

(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) : ''));

 

 

 

$col ++;

if ($col > 2) {

$col = 0;

$row ++;

}

}

Link to comment
Share on other sites

Hi there, tried using that contribution and it seems its not compatable in its whole form when i uploaded but i would like to add the if statements so i can use the script i pasted above but add the sold out script to it.

 

Can you help me out?

Link to comment
Share on other sites

Hi there, tried using that contribution and it seems its not compatable in its whole form when i uploaded but i would like to add the if statements so i can use the script i pasted above but add the sold out script to it.

 

Can you help me out?

You'll have to get the product quantity for the products so with the

$new_products_query =

parts you should add the field p.products_quantity so it looks like (for both queries)

 $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_quantity, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

Then after the

while ($new_products = tep_db_fetch_array($new_products_query)) { 
$new_products['products_name'] = tep_get_products_name($new_products['products_id']);

you should get something like

   if ($new_products ['products_quantity'] > 0) {

$info_box_contents[$row][$col] = array('align' => 'center',
'params' => 'class="smallText" width="33%" valign="top"','text' => 

'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>
<form name="cart_quantity" method="post" action="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'). '"><input type="hidden" name="products_id" value="' . $new_products['products_id'] . '"><input type="text" name="quantity" value="1" maxlength="5" size="5"><br>' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form><br>
<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '"><br>' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif') . '</a><br>' .
(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) : '')); 

} else {

$info_box_contents[$row][$col] = array('align' => 'center',
'params' => 'class="smallText" width="33%" valign="top"','text' => 

'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=shadow1') . '</a><br>
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' .  tep_image('soldoutorsomething.gif', ' alternate text' ) . '<br>
<a title="more info" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '"><br>' . tep_image(DIR_WS_IMAGES . 'more-info-sml.gif') . '</a><br>' .
(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) : '')); 

}

 

Untested !

Link to comment
Share on other sites

Is there anyone out there that could help me with this i'm trying to add a quantity box in my products_new.php to display it above the button in cart button. Where and what do i need to add?

 

<?php

if ($products_new['products_quantity'] <=0) { ?>

<td align="center" valign="middle" class="main"><?php echo tep_image_button('button_in_cart_na.gif', IMAGE_BUTTON_IN_CART_NA) ; ?></td>

<?php

} else { ?>

<td align="center" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

<?php

} ?>

Link to comment
Share on other sites

also trying to get this to work in specials.php

 

i think the if statement is wrong for starters - can anyone help please?

 

<?php

if ($products_specials['products_quantity'] <=0) { ?>

<td align="right" valign="middle" class="main"><?php echo tep_image_button('button_in_cart_na.gif', IMAGE_BUTTON_IN_CART_NA) ; ?></td>

<?php

} else { ?>

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

<?php

} ?>

Link to comment
Share on other sites

also trying to get this to work in specials.php

 

i think the if statement is wrong for starters - can anyone help please?

 

<?php

if ($products_specials['products_quantity'] <=0) { ?>

<td align="right" valign="middle" class="main"><?php echo tep_image_button('button_in_cart_na.gif', IMAGE_BUTTON_IN_CART_NA) ; ?></td>

<?php

} else { ?>

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

<?php

} ?>

 

The statement by itself is okay but you'll have to look for what array name the product details are read into.

If that is the array called $specials your if-statement should be

 <?php 
  if ($specials['products_quantity'] <=0) {
?>

and also don't forget to add the

p.products_quantity

to the query where the product details are read from the database.

 

p.s. If you are going to ask questions within a thread which started with something different it's unlikely you will get an answer on your subsequent questions as people will not look very quickly anymore into such thread !

Link to comment
Share on other sites

specials.php trying to get quantity box above button_in_cart button can this be done? all help gratefully received

 

 

<?php

if ($specials['products_quantity'] <=0) { ?>

<td align="right" valign="middle" class="main"><?php echo tep_image_button('button_in_cart_na.gif', IMAGE_BUTTON_IN_CART_NA) ; ?></td>

<?php

} else { ?>

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

<?php

} ?>

Link to comment
Share on other sites

products_new.php trying to get quantity box above button_in_cart button can this be done? all help gratefully received

 

<?php

if ($products_new['products_quantity'] <=0) { ?>

<td align="center" valign="middle" class="main"><?php echo tep_image_button('button_in_cart_na.gif', IMAGE_BUTTON_IN_CART_NA) ; ?></td>

<?php

} else { ?>

<td align="center" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

<?php

} ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...