shaunklink Posted August 6, 2005 Share Posted August 6, 2005 I know how to do this with any button from any page, however, I was wondering how I would go about putting code into the cart that would only allow you to do it once. here is my example: I have "ORDER" buttons on the main nav of my site (which is using STS, so I stole the OSC form for "cart_quantity"), as well as the footer of my site. Basically anywhere a user is, if they click "ORDER", the item is added to the cart and then the user is sent to the cart to checkout. the problem is, if they click "ORDER" again, it then adds 1 to the QTY. I would like to know how I would make the code that would only allow you to use those buttons ONCE to add to the cart....I don't want to disable them though, as they still lead to the cart itself. any help would be appreciated....I don't need the exact answer, I am sure I can figure out how to code it, I just don't know where to start OR what page to start on. thanks! Link to comment Share on other sites More sharing options...
shaunklink Posted August 6, 2005 Author Share Posted August 6, 2005 BTW, to see what I mean, go to http://www.i-muffs.com site is test server only...... Link to comment Share on other sites More sharing options...
luxor Posted August 6, 2005 Share Posted August 6, 2005 I assume your trying to add more items to the shopping cart after adding other items which have disappeared and is now only showing the product currently being added. This is because of the session id. Let me give a few pointers : I have my external links to the product_info.php?product=whatever (there is contrib somewhere that allows you to edit the continue shopping buttons on the shopping cart to get back to the external pages search for it ) you will need this : http://www.oscommerce.com/community/contributions,3257 take the code from example.php in the above contribution and place it on all of the pages which will have order buttons on it ( setting the osCsid portion of the url = to $osCsid (variable created by above contribution. Now comes the tricky part you must set the osCsid id prior to launching the oscommerce system so that the osCsid will remain the same through the entire session. WHat I did was placed an 1px w 1px h iframe on the bottom of my index inside an if statement checking to see if $osCsid was null. If its null then the iframe will load the index.php of oscommerce hence setting the $osCsid After all of this is done you set the buy button on your external page to link to product_info.php?product=whatever&osCsid=$osCsid This will preserve the shopping cart perfectly! CHEERS Link to comment Share on other sites More sharing options...
shaunklink Posted August 7, 2005 Author Share Posted August 7, 2005 I assume your trying to add more items to the shopping cart after adding other items which have disappeared and is now only showing the product currently being added. This is because of the session id. Let me give a few pointers : I have my external links to the product_info.php?product=whatever (there is contrib somewhere that allows you to edit the continue shopping buttons on the shopping cart to get back to the external pages search for it ) you will need this : http://www.oscommerce.com/community/contributions,3257 take the code from example.php in the above contribution and place it on all of the pages which will have order buttons on it ( setting the osCsid portion of the url = to $osCsid (variable created by above contribution. Now comes the tricky part you must set the osCsid id prior to launching the oscommerce system so that the osCsid will remain the same through the entire session. WHat I did was placed an 1px w 1px h iframe on the bottom of my index inside an if statement checking to see if $osCsid was null. If its null then the iframe will load the index.php of oscommerce hence setting the $osCsid After all of this is done you set the buy button on your external page to link to product_info.php?product=whatever&osCsid=$osCsid This will preserve the shopping cart perfectly! CHEERS <{POST_SNAPBACK}> thanks for your help, your intentions are admirable.....however it is not at all what I meant :) please visit the link above to see what I am talking about. to sum it up though... the site only sells 1 product....so there is no problem adding anything else to the cart. I have an "ORDER" button on the top of the page in the main NAV. Since I am using STS I merely created the nav buttons with CSS and html. These nav buttons reside OUTSIDE of the osCommerce code....I.e. no tep_ref_html('etc, etc') calls...straight up HTML. for the order button on the main nav, I used the same exact form call that the "ADD TO CART" button does within osCommerce (the form call was taken from product_info.php line 47 or so) <?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?> anyways, I created a form with the same actions and put it in the "ORDER" button on the main nav. It works great......it adds 1 product to the shopping cart and then the user is re-directed to the shopping cart to edit their order or checkout (remember, only 1 product). what happens though is say a customer clicks the "ORDER" button on the main nav, and then after being sent to the shopping cart, they click somewhere else on the site....then, they click "ORDER" again.... what this does, is add 1 more to the cart. basically the "ORDER" button merely ads 1 to the cart every time it is clicked. what I want to do, is figure out a way to only let the user add 1 with the "ORDER" button, and then the button will no longer add 1 to the QTY if a user clicks it again....I still want it to send the user to the cart page though, so de-activating the button is a no no..... Link to comment Share on other sites More sharing options...
shaunklink Posted August 7, 2005 Author Share Posted August 7, 2005 BTW, I use the contrib you mentioned above! it works great dosn't it!?!?! Link to comment Share on other sites More sharing options...
luxor Posted August 7, 2005 Share Posted August 7, 2005 ok what your trying to do is very easy.. You can disable the order button with a simple if statement. You will have to figure out how to read the cart content from the session variable this is not the exact syntax but here is the code logic you will need: <? if session (cart_variable) !=NULL echo "<a href=shopping_cart>order_button_picture</a>"; else echo "<a href=order_product>order_button_picture</a>"; ?> put that in the place of the button and it should work . Link to comment Share on other sites More sharing options...
shaunklink Posted August 7, 2005 Author Share Posted August 7, 2005 thanks, your logic makes perfect sense....the only problem that I forgot is that STS template system does NOT parse PHP......damn!!!! I'll figure something out.......although, if you think about it, who really is going to keep hitting the "ORDER" button.. thanks again Link to comment Share on other sites More sharing options...
luxor Posted August 7, 2005 Share Posted August 7, 2005 What I did with my site is have the external pages and sts_template identical and handle all functions on my external pages, with only calling the sts template when adding items to cart , check out , etc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.