godino1 Posted December 31, 2005 Share Posted December 31, 2005 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 More sharing options...
wheeloftime Posted January 1, 2006 Share Posted January 1, 2006 Take this contribution as a sample. It explains what you are trying to do. HNY ! Link to comment Share on other sites More sharing options...
godino1 Posted January 1, 2006 Author Share Posted January 1, 2006 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 More sharing options...
wheeloftime Posted January 1, 2006 Share Posted January 1, 2006 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 More sharing options...
godino1 Posted January 1, 2006 Author Share Posted January 1, 2006 thanks m8 it worked perfectly Link to comment Share on other sites More sharing options...
godino1 Posted January 1, 2006 Author Share Posted January 1, 2006 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 More sharing options...
godino1 Posted January 2, 2006 Author Share Posted January 2, 2006 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 More sharing options...
wheeloftime Posted January 2, 2006 Share Posted January 2, 2006 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 More sharing options...
godino1 Posted January 2, 2006 Author Share Posted January 2, 2006 <?php if ($specials['products_quantity'] <=0) { ?> that worked fine it was me with the if statement wrong the rest i remembered to do thanks so much Link to comment Share on other sites More sharing options...
godino1 Posted January 2, 2006 Author Share Posted January 2, 2006 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 More sharing options...
godino1 Posted January 2, 2006 Author Share Posted January 2, 2006 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 More sharing options...
godino1 Posted January 2, 2006 Author Share Posted January 2, 2006 can anyone hello me on my last two entrys????? Link to comment Share on other sites More sharing options...
godino1 Posted January 3, 2006 Author Share Posted January 3, 2006 Has no one done this on there sites? Link to comment Share on other sites More sharing options...
godino1 Posted January 3, 2006 Author Share Posted January 3, 2006 can anyone hello me on my last two entrys????? I meant help me out on adding the quantity boxes Link to comment Share on other sites More sharing options...
godino1 Posted January 4, 2006 Author Share Posted January 4, 2006 Hasn't anyone done this on their website? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.