PDA

View Full Version : Can you point me to a good simple shopping script plz?


bazz
03-12-2005, 06:41 PM
Hi,

Imagine a business selling six products where each customer would buy only one main product. Then each potential customer will choose from an options list where the items are additional to the main selected product. There should be up to ten optional extras.

I am looking for a simple script (I dont think I need a cart), where they enter their choice of both main product and then their preferred options, so that as each check box is clicked, the price on the page changes to reflect their selections.

It doesn't matter if the script has to reload to show the price updates as I would prefer to enable purchases by those who have JS switched even though most of my local clients haven't a clue how to do that or even, that you could. (bless) :)

Maybe it isn't a straight forward cart that I need but I am asking here for pointers, rather than your time in developing a script because you have given so much help to date and I'm beginning to feel guilty.

So any help would be appreciated
Bazz

mlseim
03-12-2005, 08:32 PM
Bazz,

Do you have a flat-file database set up for this yet?

something like:
main item|50.00|opt1|5.00|opt2|2.50|opt3|5.00|opt4|2.50|opt5|5.00|... etc

I think you should develop some sort of scheme for this.
... and I'm assuming it's part of the hotel menu items? Maybe you already
have something in place (how you create the menus)?

Perl can refresh each time, without the need for Javascript.

Cookies would be really important here.
As items are added, you don't want to keep building up a transfer
of variables on the URL address line.

Did you ever get "cookie.lib" uploaded and practice using it?

--max--

P.S. and don't feel guilty. You wouldn't believe how much I
learn from researching various methods - to create examples
for you to use. I'm sort of learning as I go along, just like you.


.

bazz
03-12-2005, 08:46 PM
Bazz,

Do you have a flat-file database set up for this yet?

something like:
main item|50.00|opt1|5.00|opt2|2.50|opt3|5.00|opt4|2.50|opt5|5.00|... etc


nope but I can work on it now. I just needed to get a pointer in which way to go so that I wouldn't have to stop and chnage tack part way through.


... and I'm assuming it's part of the hotel menu items? Maybe you already
have something in place (how you create the menus)?


It is for five main products, a package for Bed&breakfast, one for guesthouses, one for hotels, one for self-catering and one for restaurants.

They will buy the package for thier busines type and then add from a selection of options, some extras to suit thier own specific requirements. examples of these would be additional photos, additonal email addresses, addiotnal editable pages etc.


Perl can refresh each time, without the need for Javascript.

Cookies would be really important here.
As items are added, you don't want to keep building up a transfer
of variables on the URL address line.


Why did I somehow know you would mention cookies? :D


Did you ever get "cookie.lib" uploaded and practice using it?


I have now d'lded cookie-lib.pl and am searching tutorials.

Bazz

mlseim
03-13-2005, 05:14 AM
In the cookie.lib file, set your domain name, and leave
the expiration date blank (so it expires when the browser
closes) ... that's it, easy.

Here's an example of how to set a couple cookies:
====================================
#!/usr/bin/perl

require 'cookie.lib';

&SetCookies('client_main_option','package 2');
&SetCookies('client_sub_option','subpack 3');
=====================================


Now, in a different script, you can read them back at any time:
======================================
#!/usr/bin/perl

require 'cookie.lib';

&GetCookies('client_main_option');
$client_main_option = $Cookies{'client_main_option'};

&GetCookies('client_sub_option');
$client_sub_option = $Cookies{'client_sub_option'};

=======================================


How about a login script that tests for valid password.
If password is OK, it sets a cookie that can be checked
at the beginning of each script:
=========================================
#!/usr/bin/perl

require 'cookie.lib';

#check to see if the cookie is already set
&GetCookies('user');
$username = $Cookies{'user'};

#if the password from a form equals the correct password or,
#the user is already logged in, continue ... otherwise $go_away subroutine.
unless (($input{'pass'} eq "open_sesame") || ($username eq "cms12345")) {
&go_away; }

#user password from form is valid, so give them the proper login cookie.
&SetCookies('user','cms12345');

=======================================================


The key thing to remember:

If you set a cookie at the beginning of a script, you cannot read it
unless 1) the script is re-started 2) you run another script.

It takes one refresh to write the cookie onto the user's PC.

--have fun--