Page 1 of 1

shopping cart

Posted: Thu Dec 10, 2009 1:18 am
by nga
Hello guys, i want to create a shopping cart on my website. It wouldnt lead to payment gateway but only record the items selected into my database.

Requirements: The shopping pages will contains differents categories, breadcrumbs and pagination. Of course users will be able to choose items across pages and categories.

So my questions are:

- Should i make the shopping page 1 page (using $_get to get page id, category etc)
( requirements is listed above
)- Should i store the items in hidden fields which get pass on to the next shopping page or use cookies?
- Number of items selected should be limited or unlimited?
- Is there any issue involving developing shopping carts? (as i mentioned, it wont lead to payment gateway). I'll escape the string input into the database, check product id if it doesnt exists...

or should i buy/ download a free shopping cart from somewhere (please mention the link if you know any free + good one)

I browsed through different shopping carts online, so expensive :crazy: ! so i think there must be something hard to develop 1 yourself? Any extra requirements in develop a shopping cart beside the one i listed above?

Re: shopping cart

Posted: Thu Dec 10, 2009 9:21 am
by _64k
I'm actually developing e-commerce functionality for a company at the moment. My thoughts would be


Q: Should I make the shopping page 1 page (using $_get to get page id, category etc) ?

A: I believe this question is asking, should you use your URL to control if a display a Product, a Category of Products etc is shown and yes using $_GET to access the URL attributes is a common method, taking that a step further a .htaccess file can then be used to direct SEO friendly URL to this page and use the URL attributes to control it.

Q: Should I store the items in hidden fields which get pass on to the next shopping page or use cookies?

A: I would preferably use hidden fields as that would work well if you chose to go down the route of Q1.

Q: Number of items selected should be limited or unlimited?

A: Completely up to you really. performance wise the larger the table the long it will take to query, however this is probably not going to be a factor for a small/medium sized site. if it is, there are a number of mySQL tweaks that can be implement to help increase performance.

a good example of a simple shopping cart written in PHP is http://www.phpwebcommerce.com/php-mysql ... torial.php . I used this for a base when creating my first, it helped greatly in the learning process.

:) hope that helped

Re: shopping cart

Posted: Sun Dec 13, 2009 9:40 pm
by nga
i havent think it through i think...

So i'm trying paging with passing hidden fields.
The problem is if i click page 2 for example and i want to post the hidden field via post, i have to use documen.form1.submit() (javacript) to post the data but the submit() will lead the page to action link <form id="form1" name="form1" method="post" action="checkout.php">) not page 2 ToT

Re: shopping cart

Posted: Mon Dec 14, 2009 3:38 am
by nga
i move on using session... hidden fields are so bad...... and cant keep info any more if customer arent in shopping pages any more. Recommend nobody uses this way

question 2: so it goes like this, i have a home page allow people to key in information then click next to shop and go to shopping pae. the flow is perfect: home (type in info)-> shopping pages -> checkout (actually place an order into my database)

Now, i want to allow people to start from shopping to shop and return to home page to key in info. Now the flow is messup. They can either:
shoping->home
home->shoping
shoping->checkout
home-> checkout

so naturally, i have 2 buttons on home: shop or check out (if they already shopped)...
the thing is session can only be written after they click submit... (cause dont want to use java or ajax...). From home page, if they click shop-> submit go to shop (post data got posted) but if checkout is click, in order for post data to got posted, the form need to be submit which will goes to action="shop"... help...