Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Add To Cart on Existing Pages


Recommended Posts

Hello everyone,


I've been searching the forums here and the internet for a few days now trying to find out how to do what I need, and have been met with very little progress. Here's my situation, my client already has a website with existing pages for each product he sells (20-30 at this time). He wants to improve his sales by allowing customers to purchase directly off his site (rather than having to call in to place an order).


What I want to be able to do is have the user click 'add to cart' on the product pages that already exist, and then from there link directly to the cart page in OSC. My client finds the layout of the OSC pages not to his liking, and rather than wait to have those pages re-designed to match the current layout, he feels it a much better idea to use the existing pages. I understand that I will need to have the session ID maintained from as soon as the user enters the site (and in order to prepare for this I have moved the entire site contents into my OSC root folder). What I need someone to tell me is which code from index.php in OSC do I need to add to my existing pages in order to have all the 'hidden' cart functionality that the user doesn't see function on all existing product pages.


Ultimately my goal is to have the site flow as such > user enters www.domain.com and site main page comes up and they can begin browsing > user reads about products, and then finds the one they want > select quantity from drop-down list > click 'add to cart' > be directed to the shopping cart page in OSC to finish checkout process.


I am on a tight time frame here and any help that could be offered would be much appreciated.


Thanks in Advance

Link to comment
Share on other sites

The "overhead" in osCommerce is done in /includes/application_top.php


The osC files "require" this right up front:


A code excerpt:


 $Id: index.php,v 1.1 2003/06/11 17:37:59 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License


It keeps the session ID and does all the overhead tasks.


In your osC Admin you'll need to set "Display Cart After Adding Product" to false on the Configuration page.


If it's true you get sent to the shopping cart page after adding a product. Set false, you get sent back to the referring page.


A sample of the HTML used for the "Add to cart" might look something like this:


<form name="cart_quantity" action="http://www.website.com/catalog/product_info.php?products_id=63&action=add_product" method="post">
  <input type="hidden" name="products_id" value="63">
  <input type="image" src="includes/languages/english/images/buttons/button_in_cart.gif" border="0" alt="Add to Cart" title=" Add to Cart ">


In that code products_id=63 and value="63" defines the product from the osC DB.


This ought to give you a starting point.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.


"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -


"Headers already sent" - The definitive help


"Cannot redeclare ..." - How to find/fix it


SSL Implementation Help


Like this post? "Like" it again over there >

Link to comment
Share on other sites

  • 1 month later...



This is "exactly" what I want to do, too:

Put an "Add to Shopping Cart" button onto existing web pages.


I've looked through the docs and the FAQ and have successfully installed OSC into /catalog, but from here on I'm lost. Is there any info out there? This must be a frequent question.



Link to comment
Share on other sites

The problem with putting Add To Cart buttons outside of osCommerce is that if the product has attributes then it goes to the Product Info page anyway, because that's where you select the attribute.



Link to comment
Share on other sites


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

  • Create New...