PDA

View Full Version : Custom Shopping Cart - Linking to Database?


colinkites2000
05-14-2009, 11:06 PM
Hi Everyone,

I've been plugging away at taking our website (www.abraDELETETHISmetal.com) to take online orders. The original plan was to use PHPCart (www.phpcart.net) to generate the code for an "ADD TO CART" button that I would add beside each of my items in the tables. I tested this and it worked fine, except that updating a lot of pricing was going to be labor-intensive. I would need to change the price in the HTML table listing and then change the pricing of the PHPCart button as well. So I decided it would be nice to have some dynamic tables through MySQL/PHP so that we could make bulk updates quickly in excel and also to add new items this way to the tables. That seems to be working well. At this point, I can update the pricing (and other information) quickly and easily using the database but since the PHPCart button is not linked to the database, I would need to also make the adjustment for that. Also, the thought of hand entering 1000 items to make the order button begs me to research this before going through with that.

Ideally, I would like to be able to have the order button call my database and determine the pricing and item description from that. Is this possible? PHP? Software? I am competent in HTML and just getting started in PHP/MySQL. It is essential to keep the look of the site nearly identical and hopefully use our current database.

Any insights greatly appreciated.

Sincerely,
Colin

Fumigator
05-14-2009, 11:11 PM
This is definitely something you need to use a server-side language (PHP or whatever) to do. Your online catalog's HTML should not be hand-coded-- a PHP script should generate the HTML based on what's in your database.

colinkites2000
05-14-2009, 11:35 PM
Thanks Fumigator - I am actually using PHP and MySQL now to generate the tables dynamically. But it's the button for the add to cart that I need to figure out - how to link to the database to get the pricing etc.

Old Pedant
05-15-2009, 12:34 AM
...but since the PHPCart button is not linked to the database,...

Ummm...WHY isn't it linked to the database???

And why is it only a button? You expect that nobody will ever order more than one of an item?

The usual way to do this is to allow the user to enter a quantity and then push an add to cart button.

That results in sending both the quantity and the product id to the server side code. The server side code connects to the same DB that generated the product listing and gets the price, along with any other needed info, to generate the cart records.

You *can* pass the price to the server, along with the quantity and productid, of course. But what happens if somebody spoofs your site and changes the price to a penny?

It sounds to me like whatever you are using for "add to cart" is in need of some rework. It may not be up to commercial quality.

colinkites2000
05-15-2009, 01:18 AM
Hi - thanks for the reply. The cart software is not capable of linking to my database. When I got it, I didn't think that a database was necessary - and I was under the impression that I would have to conform the site in undesirable ways to implement database driven carts.

I've changed my mind now and believe there must be a product or coder out there that can take care of adding the items to the cart by using the information straight from the database or from the dynamic table. Do you have any recommendations for how to proceed? I'm not up to the level to write the necessary code for the add to cart form.

We will review all the orders that come in at the store before processing to be sure everything is in stock etc.... and so if someone managed to change a price, we would detect that when entering the order into the POS / Inventory system. At the moment, the user can control quantities at the shopping cart page but you're right - maybe a form would be better. C

Old Pedant
05-15-2009, 01:53 AM
So *IS* the cart software capable of being passed *all* the information: productid, product description, quantity, price????

If so, you could just rebuild the HTML you generate so that indeed it passes all that stuff.

Sorry, I'm not a PHP person. If you asked me for recommendations for ASP.NET or JSP, then maybe.

I have to say that any shopping cart software that can't be linked to a database is worthless, in my estimation.

*******************

Okay, so I went and looked at the product. A joke. No database support means the orders don't get saved in a database. Unusable for any but the very very smallest operations.

However...

I do see that their "add to cart" link *CAN* take the price and quantity and all the other stuff.

Here's an example from their demo page:

http://www.phpcart.net/demo/phpcart/phpcart.php?action=add&id=HOWTO&descr=Book+-+How+To+program+in+PHP&price=18.89&quantity=1&key=9a2fc8bed53545bd1906ce6236265701

See? Right there, you get to pass the product id (id), the description (descr), the price (price) and the quantity (quantity). So why don't you just do that???


Here's a funny one: If you actually click on that link on their demo page, you get a PHP error!
Parse error: syntax error, unexpected '[' in /home/ghubertphp/public_html/demo/phpcart/localization/french.php on line 2
TOO FUNNY! LMAO.

Old Pedant
05-15-2009, 01:57 AM
Having said all that I have, I have to think that the root problem here may be in how you are generating your catalog pages and then how you are generating the links to the phpcart.php pages.

I think it's time to post some of your code.