danicasati Posted December 1, 2005 Share Posted December 1, 2005 Hello. In product listing (not product_info.php), I need to disable "BUY NOW" button (in "BUY" column only if stock products is = 0. How can I do this? There isn't any contribution that answer this question. :( Thank you. Link to comment Share on other sites More sharing options...
boxtel Posted December 1, 2005 Share Posted December 1, 2005 Hello.In product listing (not product_info.php), I need to disable "BUY NOW" button (in "BUY" column only if stock products is = 0. How can I do this? There isn't any contribution that answer this question. :( Thank you. just put the button code in a condition : if ($listing['products_quantity'] > 0) { button code } Treasurer MFC Link to comment Share on other sites More sharing options...
shadow-13x Posted December 2, 2005 Share Posted December 2, 2005 just put the button code in a condition : if ($listing['products_quantity'] > 0) { button code } what file would that be in? is that the exact code to replace what? I have been having people order things that have zero stock. ThE sHaDoW Link to comment Share on other sites More sharing options...
laurelsstitchery Posted December 2, 2005 Share Posted December 2, 2005 Yes, I need this information as well. what file would that be in?is that the exact code to replace what? I have been having people order things that have zero stock. ThE sHaDoW Laurel Link to comment Share on other sites More sharing options...
danicasati Posted December 5, 2005 Author Share Posted December 5, 2005 just put the button code in a condition : if ($listing['products_quantity'] > 0) { button code } This code doesn't work for all products in the list! For example, first 2 products with stock = 0 are displaying correctly without buy button, but the next ones display the ADD BUTTON. Why? Link to comment Share on other sites More sharing options...
boxtel Posted December 5, 2005 Share Posted December 5, 2005 This code doesn't work for all products in the list!For example, first 2 products with stock = 0 are displaying correctly without buy button, but the next ones display the ADD BUTTON. Why? like this? case 'PRODUCT_LIST_BUY_NOW': if ($listing['products_quantity'] > 0) { $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; Treasurer MFC Link to comment Share on other sites More sharing options...
danicasati Posted December 5, 2005 Author Share Posted December 5, 2005 I have the following code into my product_listing.php: case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $form = tep_draw_form ('cart_quantity', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'),'post',''); $buy_now_button = tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART); $submit_product_quant = '<input type="text" name="cart_quantity" value="1" maxlength="2" size="2">'; $hidden = tep_draw_hidden_field ('products_id', $listing['products_id'],''); $endform = '</form>'; if (PRICES_LOGGED_IN == 'false') $buy_now_button_d = $buy_now_button; if ( (PRICES_LOGGED_IN == 'true') && (!tep_session_is_registered('customer_id'))) { $buy_now_button_d = '<a href="' . tep_href_link(FILENAME_LOGIN, '','SSL') . '">' . PRICES_LOGGED_IN_BUY_TEXT . '</a>?'; } else { $buy_now_button_d = $hidden . $submit_product_quant . '?'. $buy_now_button; } $lc_text = $form . $buy_now_button_d . $endform; break; } I'm using osCommerce 2.2 Ms2 with B2bSuite. How can I change this code to hide BUY BUTTON if quantity is = 0? Link to comment Share on other sites More sharing options...
♥Vger Posted December 5, 2005 Share Posted December 5, 2005 I have been having people order things that have zero stock In which case all you have to do is to set Allow Checkout to false in your osCommerce admin panel, under Configuration --> Stock, and people will not be allowed to purchase items with zero stock levels. Vger Link to comment Share on other sites More sharing options...
boxtel Posted December 5, 2005 Share Posted December 5, 2005 I have the following code into my product_listing.php: case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $form = tep_draw_form ('cart_quantity', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'),'post',''); $buy_now_button = tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART); $submit_product_quant = '<input type="text" name="cart_quantity" value="1" maxlength="2" size="2">'; $hidden = tep_draw_hidden_field ('products_id', $listing['products_id'],''); $endform = '</form>'; if (PRICES_LOGGED_IN == 'false') $buy_now_button_d = $buy_now_button; if ( (PRICES_LOGGED_IN == 'true') && (!tep_session_is_registered('customer_id'))) { $buy_now_button_d = '<a href="' . tep_href_link(FILENAME_LOGIN, '','SSL') . '">' . PRICES_LOGGED_IN_BUY_TEXT . '</a>?'; } else { $buy_now_button_d = $hidden . $submit_product_quant . '?'. $buy_now_button; } $lc_text = $form . $buy_now_button_d . $endform; break; } I'm using osCommerce 2.2 Ms2 with B2bSuite. How can I change this code to hide BUY BUTTON if quantity is = 0? b2bsuite, that is a valuable piece of information don't you think? Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted January 3, 2006 Share Posted January 3, 2006 I'm in a similar pickle here. I want the Buy Now to appear only when there's stock available. I believe I've found the correct place; includes/modules/product_listing.php and I've found the code Amanda has mentioned. When I add the code, all of my Buy Now links disappear regardless of stock level and the price appears. I have the Short Description Contribution added and think maybe that's the issue. It isn't the end of the world without this fix, but I have a nice bit worked out with the product notification on the product's page. I'd rather they clicked through to there to see it is out of stock and had the chance instead of being disappointed on the cart page. Here's (what I think) is the relevant code, showing some of the product description hack. // Products Description Hack begins if (PRODUCT_LIST_DESCRIPTION > 0) { $lc_params = 'rowspan="2" '; } // Products Description Hack ends break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename(FILENAME_DEFAULT), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . TEXT_BUY_NOW . '</a>'; break; } // Products Description Hack begins $lc_params .= 'class="productListing-data"'; if ($column_list[$col] == 'PRODUCT_LIST_DESCRIPTION') { $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => $lc_params, 'text' => $lc_text, 'desc_flag' => 'true'); } else { $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => $lc_params, 'text' => $lc_text); } // Products Description Hack ends } } new productListingBox($list_box_contents); } else { $list_box_contents = array(); I hate to fill a post with more code than necessary, but I could post my whole file (204 lines) if anyone thinks it will help. Thanks for looking! Link to comment Share on other sites More sharing options...
boxtel Posted January 4, 2006 Share Posted January 4, 2006 I'm in a similar pickle here. I want the Buy Now to appear only when there's stock available. I believe I've found the correct place; includes/modules/product_listing.php and I've found the code Amanda has mentioned. When I add the code, all of my Buy Now links disappear regardless of stock level and the price appears. I have the Short Description Contribution added and think maybe that's the issue. It isn't the end of the world without this fix, but I have a nice bit worked out with the product notification on the product's page. I'd rather they clicked through to there to see it is out of stock and had the chance instead of being disappointed on the cart page. Here's (what I think) is the relevant code, showing some of the product description hack. // Products Description Hack begins if (PRODUCT_LIST_DESCRIPTION > 0) { $lc_params = 'rowspan="2" '; } // Products Description Hack ends break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename(FILENAME_DEFAULT), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . TEXT_BUY_NOW . '</a>'; break; } // Products Description Hack begins $lc_params .= 'class="productListing-data"'; if ($column_list[$col] == 'PRODUCT_LIST_DESCRIPTION') { $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => $lc_params, 'text' => $lc_text, 'desc_flag' => 'true'); } else { $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => $lc_params, 'text' => $lc_text); } // Products Description Hack ends } } new productListingBox($list_box_contents); } else { $list_box_contents = array(); I hate to fill a post with more code than necessary, but I could post my whole file (204 lines) if anyone thinks it will help. Thanks for looking! case 'PRODUCT_LIST_BUY_NOW': if ($listing['products_quantity'] > 0) { $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename(FILENAME_DEFAULT), tep_get_all_get_params(array ('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . TEXT_BUY_NOW . '</a>'; } break; !! But make sure you DO select products_quantity in your query which is provided to products_listing.php !! Treasurer MFC Link to comment Share on other sites More sharing options...
gareth123456 Posted January 4, 2006 Share Posted January 4, 2006 Have you tried the Disable Buy Now if Price = 0 Contribution? Link to comment Share on other sites More sharing options...
Guest Posted January 4, 2006 Share Posted January 4, 2006 Thank you, Gareth, but that's not what I'm after. Amanda, Thanks for getting back to me so quickly! I'm looking through the queries in index.php and so far I think I've found the right one. I've added p.products_quantity, to each of four queries and put back the code you mentioned before. Now, it looks like it is picking up the quantities and showing the buy it now text I want when a product is available. Thanks! However, it still shows a repeat of the price in place of the buy it now text for something sold out. Do you think it's because I'm missing an "else" statement? I don't see any place where it should pick that price up to display it. I just tried adding an else statement with pixel_trans.gif. It didn't pick it up and still shows the price for sold out items. Any thoughts? Link to comment Share on other sites More sharing options...
Guest Posted January 4, 2006 Share Posted January 4, 2006 Gareth, I'm so sorry to have dismissed your help!! Inside that Contrib was the answer! It gave me the proper else statement I needed. Anyone looking to do the same should follow Gareth's link. Thanks, bud! I won't be so hasty next time! :D Link to comment Share on other sites More sharing options...
epch000 Posted July 22, 2008 Share Posted July 22, 2008 case 'PRODUCT_LIST_BUY_NOW': if ($listing['products_quantity'] > 0) { $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename(FILENAME_DEFAULT), tep_get_all_get_params(array ('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . TEXT_BUY_NOW . '</a>'; } break; !! But make sure you DO select products_quantity in your query which is provided to products_listing.php !! Amanda absolulty right: I suggest an IF modification to: if ($listing[$x]['products_quantity']<=0) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.