pejo Posted February 1, 2007 Posted February 1, 2007 I'm integrating OSCommerce with my sight that is already built. I want the continue shopping button to back to the last page. I'm not using the osCommerce product pages...instead I'm using my own. My intention is to use oscommerce and build all the product pages etc necessarry and just copy the forms and links created on them to my existing page (I'm sure I'll have to throw some of the php session stuff as well) But for now I just want to have the continue button go back to my showroom page....instead it always goes to the product page for the item that is created in oscommerce and not just 'back 2 pages' as I've read elsewhere in this forum. tia. pete. my site is www.aquariumtoilets.com It is my site not a job I'm doing either so I have the freedom to do anything I like... but I just don't want to have to rebuild the whole damn thing in OsCommerce to get it to work right....
Velveeta Posted February 1, 2007 Posted February 1, 2007 I'm integrating OSCommerce with my sight that is already built. I want the continue shopping button to back to the last page. I'm not using the osCommerce product pages...instead I'm using my own. My intention is to use oscommerce and build all the product pages etc necessarry and just copy the forms and links created on them to my existing page (I'm sure I'll have to throw some of the php session stuff as well) But for now I just want to have the continue button go back to my showroom page....instead it always goes to the product page for the item that is created in oscommerce and not just 'back 2 pages' as I've read elsewhere in this forum. tia. pete. my site is www.aquariumtoilets.com It is my site not a job I'm doing either so I have the freedom to do anything I like... but I just don't want to have to rebuild the whole damn thing in OsCommerce to get it to work right.... Sometimes this can be done with a javascript function, but to protect against browsers with javascript disabled, you could always do something like this: When a product's info page is clicked on, and the page is rendered on the server side, when you construct the form to make the add to cart button, check for a hidden field called something like "referer_page", and if it exists, don't reassign it, but if it doesn't exist, create that hidden field and give it a value of: echo $_SERVER['HTTP_REFERER']; [/code Which holds the value of the page they came from when they clicked on that product to view its info... Wire that value to the link that's behind the Continue Shopping button, and this is how it should behave: If they click into that product's page for the first time, $_SESSION['referer_page'] won't exist, so it will use the $_SERVER['HTTP_REFERER'] value to create that hidden field in the form for adding the product to the cart, as well as making the url of the Continue Shopping button equal to that... If they add the product to the cart, if you have it set to return to the product info page, then the code in application_top.php that adds it to the cart can check for $_POST['referer_page'], and if it exists, it can create the session value with something like this right before the tep_redirect: [code] $referer_page = $_POST['referer_page']; tep_session_register('referer_page'); The reason for this is that the post variables will be destroyed when the redirect happens, so you want to save that page value in the session data... Then the customer is returned to the product page, and when constructing that form, $_SESSION['referer_page'] *will* exist, so it will use that value rather than recreating the variable from scratch, because how $_SERVER['HTTP_REFERER'] equals that same page, since you're coming from that page back to itself when you clicked the add to cart button... So it will use the original value stored in $_SESSION['referer_page'] to wire to the Continue Shopping button, and to create the hidden field in the add to cart form (in case they click to add another to their cart)... Then you destroy the session variable with: tep_session_unregister('referer_page'); And that should do it... This may sound a bit convoluted and dizzying depending on how new you are to osc and php in general, but it's really only adding a few lines of code... Richard. Richard Lindsey
pejo Posted February 1, 2007 Author Posted February 1, 2007 OK Thanks Richard. I think I got the gist of it. It's been a while since I've done any php programming..and completely new to osC I'm a pretty quick study and your explanation was great. pete. Sometimes this can be done with a javascript function, but to protect against browsers with javascript disabled, you could always do something like this: When a product's info page is clicked on, and the page is rendered on the server side, when you construct the form to make the add to cart button, check for a hidden field called something like "referer_page", and if it exists, don't reassign it, but if it doesn't exist, create that hidden field and give it a value of: echo $_SERVER['HTTP_REFERER']; [/code Which holds the value of the page they came from when they clicked on that product to view its info... Wire that value to the link that's behind the Continue Shopping button, and this is how it should behave: If they click into that product's page for the first time, $_SESSION['referer_page'] won't exist, so it will use the $_SERVER['HTTP_REFERER'] value to create that hidden field in the form for adding the product to the cart, as well as making the url of the Continue Shopping button equal to that... If they add the product to the cart, if you have it set to return to the product info page, then the code in application_top.php that adds it to the cart can check for $_POST['referer_page'], and if it exists, it can create the session value with something like this right before the tep_redirect: [code] $referer_page = $_POST['referer_page']; tep_session_register('referer_page'); The reason for this is that the post variables will be destroyed when the redirect happens, so you want to save that page value in the session data... Then the customer is returned to the product page, and when constructing that form, $_SESSION['referer_page'] *will* exist, so it will use that value rather than recreating the variable from scratch, because how $_SERVER['HTTP_REFERER'] equals that same page, since you're coming from that page back to itself when you clicked the add to cart button... So it will use the original value stored in $_SESSION['referer_page'] to wire to the Continue Shopping button, and to create the hidden field in the add to cart form (in case they click to add another to their cart)... Then you destroy the session variable with: tep_session_unregister('referer_page'); And that should do it... This may sound a bit convoluted and dizzying depending on how new you are to osc and php in general, but it's really only adding a few lines of code... Richard.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.