sf7804 Posted January 28, 2003 Share Posted January 28, 2003 Just wondering if there was a "better" way to do this. I've edited this in product_info.php, but it's rather crude. <?php if (tep_get_products_stock($products_id) > 0) { ?> <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> <?php } else { ?> <em><font color="#999999">Cannot add to cart</font></em><br> <?php echo tep_image_submit('button_in_cart_grey.gif', 'Cannot add to cart - out of stock')?> <?php } ?> It works great though ;) Link to comment Share on other sites More sharing options...
burt Posted January 28, 2003 Share Posted January 28, 2003 Untested: <?php switch (tep_get_products_stock($products_id)) { case 0: echo '<em><font color="#999999">Cannot add to cart</font></em><br>'; echo tep_image_submit('button_in_cart_grey.gif', 'Cannot add to cart - out of stock'); break; default: echo '<input type="hidden" name="products_id" value=' . $product_info_values['products_id'] . '">'; echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); } ?> Link to comment Share on other sites More sharing options...
crimsontree Posted March 23, 2003 Share Posted March 23, 2003 Where do these pieces of code get inserted? cheers, Crimsontree Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2003 Share Posted March 23, 2003 Steve, In the first post it tells you that she edited product_info.php Link to comment Share on other sites More sharing options...
crimsontree Posted March 25, 2003 Share Posted March 25, 2003 Yes I know what she said, but I don't know where the code has to be changed or inserted. cheers, Crimsontree Link to comment Share on other sites More sharing options...
digital_usa Posted March 28, 2003 Share Posted March 28, 2003 its not too hard to search for keywords used in the example to determine where they were talking about in the file... - Dan Graaff Link to comment Share on other sites More sharing options...
filth Posted March 28, 2003 Share Posted March 28, 2003 come on help the guy out, he has asked a simple question, maybe he isnt that familiar with php and would prefer to be sure before he does it. Link to comment Share on other sites More sharing options...
Guest Posted April 2, 2003 Share Posted April 2, 2003 Look for the part towards the bottom that has the button_in_cart.gif Looks like this <td align="right" class="main"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td> replace the part starting at <?php with the top code. The second code does not work Link to comment Share on other sites More sharing options...
d-woo Posted April 4, 2003 Share Posted April 4, 2003 The complete fix. Replace the following in product_info.php: <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> with the following: <?php if (tep_get_products_stock($products_id) > 0) { ?> <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> <?php } else { ?> <em><font color="#999999">Cannot add to cart at this time</font></em><br> <?php //Comment out the line below...the grey image is still clickable if you do not //echo tep_image_submit('button_in_cart_grey.gif', 'Cannot add to cart - out of stock')?> <?php } ?> The greyed image will still be clickable unless you comment out the line echo tep_image_submit('button_in_cart_grey.gif', 'Cannot add to cart - out of stock')?> Sarah...Thanks for the code!! Link to comment Share on other sites More sharing options...
crimsontree Posted May 14, 2003 Share Posted May 14, 2003 Thanks for all your help. :) cheers, Crimsontree Link to comment Share on other sites More sharing options...
valley Posted May 23, 2003 Share Posted May 23, 2003 After adding this code I get this strange behaviour from INCART BUTTON When the product quantity is 0 the button is hidden (in product_info.php) But when product quantity is not 0 I get SHOPPING CART Empty message http://affiliatesexcel.com This happens wherever the info page is called from Is anyone getting this ERROR ? Link to comment Share on other sites More sharing options...
valley Posted May 25, 2003 Share Posted May 25, 2003 Reading the various posts on the SHOPPING CART EMPTY error it appears that the most probable cause is a loss of the SID At least it seems to be the cause in this case Some how introducing the IF ELSE routine by if (tep_get_products_stock($products_id) > 0) before <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> seem to break the SID Can anyone please suggest a remedy ? I found this is a very valuable FEATURE to add to the cart as it prevents out of STOCK items and allow you to INTEGRATE EBay AUCTIONS and other memberships where you don't SELL through the cart. ( I have seen a big thread on integrating E BAY ) You can see how I am trying to do this on http://affiliatesexcel.com Menu TOP AUCTIONS Link to comment Share on other sites More sharing options...
eureka Posted June 17, 2003 Share Posted June 17, 2003 Also do the same for ../includes/modules/product_listing.php so that the button is greyed out when the products are listed, ie., (about line 147) case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; if (tep_get_products_stock($listing_values['products_id'])> 0) { $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing_values['products_id'], 'NONSSL') . '">' . tep_image_submit('button_in_cart_small.gif', TEXT_BUY . $listing_values['products_name'] . TEXT_NOW) . '</a> '; } else { $lc_text = tep_image_button('button_in_cart_small_faded.gif').' '; } break; Regards, Mark. Link to comment Share on other sites More sharing options...
valley Posted June 17, 2003 Share Posted June 17, 2003 Hello Mark after adding the above code in product_listing.php I get this error message Parse error: parse error in /home/affili43/affili43-www/catalog/includes/modules/product_listing.php on line 178 wich is } else { in the code /* 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', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a> '; break; } */ case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; if (tep_get_products_stock($listing_values['products_id'])> 0) { $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing_values['products_id'], 'NONSSL') . '">' . tep_image_submit('button_in_cart_small.gif', TEXT_BUY . $listing_values['products_name'] . TEXT_NOW) . '</a> '; } else { $lc_text = tep_image_button('button_in_cart_small_faded.gif').' '; } break; $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text); } } new tableBox($list_box_contents, true); echo ' </td>' . "n" . ' </tr>' . "n"; } else { I still get theCART EMPTY Error after modifying the codes in i the product_info.php and product_listing .php Link to comment Share on other sites More sharing options...
valley Posted June 18, 2003 Share Posted June 18, 2003 I have sort of managed to integrate our E Bay auctions in the cart. See http://affiliatesexcel.com Graying out the INCART button will be a grate feature. If any of the experts of osC could help with the issues (ABOVE POSTINGS)with getting it workig properly it will be a great step towards integrating AUCTIONS or external linksin to osc Link to comment Share on other sites More sharing options...
eureka Posted June 26, 2003 Share Posted June 26, 2003 Also need to do the same treatment for .. /includes/modules/products_new.php (about line 35). <td align="right" valign="middle" class="main"><?php if (tep_get_products_stock($products_new_array[$i]['id'])> 0) { echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new_array[$i]['id'], 'NONSSL') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; } else { echo tep_image_button('button_in_cart_faded.gif', IMAGE_BUTTON_IN_CART); } ?></td> Regards, Mark. Link to comment Share on other sites More sharing options...
valley Posted June 26, 2003 Share Posted June 26, 2003 Hi Mark Many thanks for the additional correction in the product_new.php Now I get the Greyed out Buton button_in_cart_small_faded.gif in product_ listing.php (default page) whether the quantity is 0 or more and "OUT of stock" comment when the quantity is 0 in th Product_info.php I still get the Shopping cart empty error in shopping cart.php when you click in cart button for a product where quantity is not 0. If you are there and want to test I have left the site with changed files (Please let me know as the site is liVe) Link to comment Share on other sites More sharing options...
eureka Posted June 27, 2003 Share Posted June 27, 2003 Hi "Valley", I'm not sure what your problem is but I suspect the problems are eleswhere ie., shopping_cart.php, and not the above scripts. I'm having no problems and there is nothing in the scripts to create problems. Sorry I can't offer more help. Good luck. Mark. Link to comment Share on other sites More sharing options...
valley Posted June 27, 2003 Share Posted June 27, 2003 Hi Mark Many thaks , it is a pity I can't get this to work Thre are TWO roblems In Product Listing BUY NOW button dsappear even when th product quantity is more than 0 When you click on IN CART button you get a message " YOURCART IS EMPTY " ONly when the mods are implemented Otherwise everything is fine I don't kow why this happens only to my cart as no one else seem to have these problems. Link to comment Share on other sites More sharing options...
Priest Posted August 6, 2003 Share Posted August 6, 2003 So is this compatible with MS2.2 ~P~ Link to comment Share on other sites More sharing options...
DicE Posted August 15, 2003 Share Posted August 15, 2003 I'm looking for sortof the same feature, but I would like the button greyed out when a product is not yet available. (when date expected > current date) anybody know what to change for that? thanks a lot for any info! DicE _____.:::.________###__________|/______ :(o o): . (o o) (o o) ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- Link to comment Share on other sites More sharing options...
DicE Posted August 20, 2003 Share Posted August 20, 2003 Hi all. is there nobody else doing that? I mean, I would like to have the greyed out button, but not when a produkt is out of stock, just when it's not yet available because it's brand new and everybody is waiting for it etc :-) that should be so hard for all you die hard coders out there !!! :P thanks!!! DicE _____.:::.________###__________|/______ :(o o): . (o o) (o o) ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.