Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Link back from Non-product/category pages


pointjg

Recommended Posts

Hey guys,

 

Is it possible to link back to the product or category page you were on before clicking a link such as Cart Contents, Checkout, Shipping & Returns, etc... ?

 

The issue is when you visit those pages you can only return all the way back to the home page or then you have to hit the back button.

 

Im wondering is it possible to create a way back to the category or product page directly? Or a link back to the top most category from every page? (I have this working in the product and category pages through breadcrumbs).

 

Thanks in advance.

Link to comment
Share on other sites

this might work:

in application_top, create a session variable that is an array with two elements. each time application_top runs, copy element [0] to element[1] and then place the value of $_SERVER['REQUEST_URI'] in element[0].

 

then, on the page in question (i.e. checkout), you can create a link to the previous page in the 'stack' by using the value in array element [1].

 

you wouldn't need to use the tep_href_link() function to create the value for the href= attribute in your <a> tag, as the request_uri would already contain this.

Link to comment
Share on other sites

this might work:

in application_top, create a session variable that is an array with two elements. each time application_top runs, copy element [0] to element[1] and then place the value of $_SERVER['REQUEST_URI'] in element[0].

 

then, on the page in question (i.e. checkout), you can create a link to the previous page in the 'stack' by using the value in array element [1].

 

you wouldn't need to use the tep_href_link() function to create the value for the href= attribute in your <a> tag, as the request_uri would already contain this.

 

Thanks for the reply and your help. I really want to test this - however my coding doesnt go much further than html/css, could you provide me with the code to make this happen?

Link to comment
Share on other sites

there's no better time to start learning php than right now. if i just give you the code you won't learn and you'll still be dependent on someone else for this sort of thing in the future.

 

there are enough examples of code within application_top to do all of this. so just take a crack at it and see where you get. if you run into problem, post them here and i or someone else may be able to help.

 

i know, probably not what you wanted to hear. :) but learning at least some of this now will help you in the future with managing your own shop. and no one else is going to do that for you.

Link to comment
Share on other sites

there's no better time to start learning php than right now. if i just give you the code you won't learn and you'll still be dependent on someone else for this sort of thing in the future.

 

there are enough examples of code within application_top to do all of this. so just take a crack at it and see where you get. if you run into problem, post them here and i or someone else may be able to help.

 

i know, probably not what you wanted to hear. :) but learning at least some of this now will help you in the future with managing your own shop. and no one else is going to do that for you.

 

No no, not at all. Ive had to modify small amounts of php before without any kind of help so this is great... Im going to take a shot at it and post what Ive got.

 

Thanks for the help :)

Link to comment
Share on other sites

Ok... Ive done some reading and I feel stupid posting this... But maybe its a start.

 

I was thinking about what you said and what if I put the script on only the index and product detail pages (that way none of the shipping, cart, etc pages would get put in the stack...)

 

$stackback=$_SERVER['REQUEST_URI']);

$_session['url']=$stackback

 

If thats right then I need to figure out howto have it run whenever either of those pages are opened along with figuring out howto make it a working link for the other pages.

 

Thanks again.

Link to comment
Share on other sites

Ok... Ive done some reading and I feel stupid posting this... But maybe its a start.

 

I was thinking about what you said and what if I put the script on only the index and product detail pages (that way none of the shipping, cart, etc pages would get put in the stack...)

 

$stackback=$_SERVER['REQUEST_URI']);

$_session['url']=$stackback

 

If thats right then I need to figure out howto have it run whenever either of those pages are opened along with figuring out howto make it a working link for the other pages.

 

Thanks again.

 

Any ideas?

 

Could I just use a referrer?

Link to comment
Share on other sites

if you only want the index and product_info pages to have the code, that's fine. but then you mention a working link for the other pages. what other pages? this is why i suggested putting something into the application_top code that will maintain the stack. all pages include application_top, so all pages would be constructing the stack. whether a pages makes use of it or not wouldn't matter, but at least they're all helping in constructing the stack.

 

you could try the referrer page. but the php documentation states "This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted." so this might work for some of your customers but not all. this is why i suggested creating a stack. it's a little more work, but will behave consistently for all users and all browsers. welcome to the world of browser incompatibilities. :)

 

also, i would suggest using the same mechanisms for setting and using session variables that the rest of the osc code does. instead of using $_session[] directly, use the tep_session_is_registered() and tep_session_register(), functions. whenever possible in osc, you should do things 'the osc' way. reason: if you make a change to the session handling functions, then all of your code's behavior will change to follow the new code. if you have some parts of your code that are not using the functions, they will not change their behavior. you'll have to go back and look for every place where you're using session variables and make sure that the code is behaving the new way. that's too much work.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...