Hi,

I was just about to write YASB (Yet Another Shopping Basket)
and I thought, hang on, there's this CPAN thing and maybe
I could get one from there.

But to my dismay I couldn't find anything! 

- So before I start writing a module I thought
I'd see what everyone want's out of a shopping basket.

I think it will be heavily based on using Apache::Session,
any other ideas / comments are very welcome.

Thanks

Leo

----------------------------------------------------------
 Shopping::Basket Proposal            Version 0.000000001
----------------------------------------------------------
Aim:
        To create a module which can be used to easily implement
        shopping baskets with lots of flexibility.

Requirements of this module:
        - Generate UID
        - Store item X in Basket Y for user UID
        - Store user details 
          (what happens if this is across multiple sites ?)
        - Password option
        - Option to validate basket item on retrieval (don't think 
           this needs to be in the module)

Functions which need to be able to be overridden (eventually)
        - Function to generate UID (might need to integrate to current system)
        - How to store the basket
                - DBI
                - File
                - anything else ?
        - Password encryption
                - standard 'salt' and 'pepper'
                - other
        - Validate of item (see requirements above)

How is the UID passwd around
        - Cookie
        - Session
        - What happens if the user needs to login, login name might not be unique.

Storage format:
        my %uid = ();

        %uid{user}{login} = 'Leo'
        %uid{user}{password} = 'wibble'
        %uid{user}{email} = '[EMAIL PROTECTED]'
        
        %uid{toys}{item_id}{id} = '2346'
        %uid{toys}{item_id}{name} = 'Furby'
        %uid{toys}{item_id}{price} = '4.99'
        %uid{toys}{item_id}{price_code} = 'GBP'
        etc..   
        
OK, so how would we use it ????

## set up basket
my $basket = Emap::Shopping::Basket->new({
     'uid_generator'  => '',    ## Will use default or call this to generate
if not
     'dbh' => $dbh,                     ## Must be parsed in with r/w permissions, 
                                        ## if not parsed in will default to file 
storage ?
     'password_generator' => '';  ## Will use default
 });


## Create a new basket
        $basket = Emap::Shopping::Basket->setup_new_user();

        ## Get the UID
        my $uid = $basket->get_uid

## Get a previous basket
        $basket = Emap::Shopping::Basket->setup_existing_user($uid);

## Add an item in
        my %details = ('id'     => '123345',
                                        'name' => 'Furby',
                                        'price' => '4.99',
                                        'price_code' => 'GBP'
                                        );

        $basket->add_item('$basket_number','item_id',\%details);

## Add user details
        ## This will override any current details of the same key
        ## but will leave all others alone.
        my %user_details = (
                                        'name' => 'leo',
                                        'password' => 'wibble',
                                        'email' => '[EMAIL PROTECTED]'
                                        );

        $basket->add_user_details(\%user_details);

## Get a list of the baskets
        my @basket_list = $basket->list_baskets();
        e.g. $basket_list[3] = 'fruit';
        
## Get a basket
        my %basket_contents = $basket->get_basket($basket_list[3]);     
        
## Delete an item
        $basket->delete_item($basket_number, $item_id); 
        
## Reports
        ## Some script to go through ALL users and their baskets
        ## and generate automatic reports.      

-----------------------------------------------------------------------
              Leo Lapworth : Technical Manager
                       tel : (020) 7309 2712 
                             ( +44 20 7309 2712 from outside the UK )
                     email : [EMAIL PROTECTED]
                       www : http://www.emaponline.com/

                  1Ski.com : http://www.1Ski.com
              Board-it.com : http://www.boardit.com
           A2bAirports.com : http://a2bairports.com
             A2bTravel.com : http://a2btravel.com
             A2bEurope.com : http://www.a2beurope.com
          EscapeRoutes.com : http://www.escaperoutes.com
           Ferrybooker.com : http://www.ferrybooker.com
       Bargainholidays.com : http://www.bargainholidays.com

This e-mail is confidential and may be privileged. It may be read, 
copied and used only by the addressee. If you have received it in 
error, please contact us immediately .
-----------------------------------------------------------------------

Reply via email to