Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

adding Url parameters and the Oscid


Recommended Posts

Hi there

doing some work on my site and want to pass a parameter in the URL

?review=review   or something like that.

When some one clicks from a product review link the URL parameter is present and  links to the product page.,. I can then manipulate the product page to show reviews at the top etc .

I am just playing around seeing what is possible and having some fun with it.

I can pass the parameter no problem and is all works however I am running into an issue with the Oscid if it is present then everything screws up.

Is there a way to code this so if the link is clicked and the Oscid is present then we get something like   https://www.url?Oscid&review=review

or even if the Oscid is present don't add the review parameter.

All help very greatfully appreciated.

 

Link to comment
Share on other sites

Parameters can be passed via PHP through a link or a form. The value of the parameter being passed must be defined in the url using the "=" sign. You can pass multiple parameters separating them with the "&" sign. 

The url you used as an example does not pass a value for Oscid. It's not quite the same as assigning a value to a PHP variable.

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Link to comment
Share on other sites

Hi there

Sorry I did not explain it very well

I pass this URL https://www.asite.com.au/aurl.html?review=review

This works fine and as expected but if the page load is the first in a session then the Oscid is added and the url doesn't work. I need to know how to code it so it will handle the Oscid if it is the first page load

 

Link to comment
Share on other sites

I'm still not really sure what you're trying to do or how the session id is causing a problem for passing parameters to another page. .. And, whether this is an internal or external link?

You can try hiding the session id via an htaccess RewriteRule script. Or, you could use a page anchor instead.

If you want the user to click a link on the product info page so that they are taken to the reviews section, you can use an anchor.

If you want that user to land on a specific review and let's say it's on a different page, you pass url parameters for that product's id and the review id.

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Link to comment
Share on other sites

12 hours ago, douglaswalker said:

I pass this URL https://www.asite.com.au/aurl.html?review=review

You shouldn't pass the full url. You should use the tep_href_link function and only provide the filename and the parameter you want to use. There is the tep_get_all_get_params function that allows you to exclude things like the session ID if it is getting picked up from the page. The session ID should only show up on the first page although, as I recall, on very old shops it would stick around for other pages. In that case, installing the Ultimate SEO url rewriter will fix that.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@Jack_mcs

Hi there

I am adding the ?review=review to this link

Could you show me how I should add it

<a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], '180', '180') . '</a>

The reviews (if they exist) on my site are all on the product page in a drop down. So I want to pass the parameter so I can alter the product page if someone comes from the review box link and place the reviews at the top.. just an idea I am working on.

Link to comment
Share on other sites

$parameters is the 2nd paramter of tep_href function, so you should add it like this:

<a href="' . tep_href_link('product_info.php', 'review=$review to this link products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], '180', '180') . '</a>

you just need to check the syntax.

Link to comment
Share on other sites

1 minute ago, bonbec said:

Perhaps like this :


<a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id']) . '?review=review">' . tep_image ...

 

This won't work, you're adding outside of the 2nd parameter.

Link to comment
Share on other sites

You need to use an "&" to add review=review instead of a "?"

The question mark follows the filename and precedes the parameters. Your first parameter is the product id, that means each additional parameter is added with a "&" sign.

And, if you are linking to a specific review for that product, you need to use the review id instead of review=review.

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

I think this is what you're looking for.

<a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id'] . '&review=review') . '">' .  ......

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

Thanks guys and works perfectly

1 hour ago, Demitry said:

I think this is what you're looking for

<a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id'] . '&review=review') . '">' .  ......

 

This is exactly what i was looking for 

Will let you now how my experiment goes

 

Link to comment
Share on other sites

@douglaswalker

You should update your PHP version asap. Otherwise, you will soon have to start from scratch with either a newer osC version or another cart software. My hosting company is now calling PHP7.3, "obsolete."

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...