Reply to Re: Advanced options in shopping cart script

Your name:

Reply:


Posted by Neil Trigger on 08/29/06 19:19

Nah, sorted...
I did it like this:
Each item has a title, recorded in the oiption_title table. This stores the
item_id and the option title. Then i have the options table which references
the option_id from the option_title table.

The option table contains price and member price as well and contains it's
own option_selected id field.

Then when I add items to the cart, I have a form on the shop index page
(which doubles as a display form for each item (depending of the $_REQUEST
value of the item_id)).

The form displays the options (if there are any) and upon submission of the
form adds the option_selected to the shopping cart variable like this:
key: 41:32:96 etc
so the first number (41) is the item id and all the others are just options.
So 32 might be "red" and 96 might be "extra large".

Then when working out the total, I find out whether the user is logged in,
if they are I see if any of the options has made the price unequal to the
default item price (also set by the administrator). Then I can either add
the default price, or the price associated with that option.

Hope this helps if anyone else ever has this problem.
But after ages trying to work out a way to do it I'm rather disinclined to
share the exact code... Sorry.

--
Neil Trigger
Magic2k Manager
http://www.magic2k.com
http://www.oddmap.com
<aaron.reese@tiscali.co.uk> wrote in message
news:1156869741.003352.322720@75g2000cwc.googlegroups.com...
> quick answer, long coding:-
>
> You could add a key value pair to the item and keep the value as a key
> value array and therefore have nested arrays.
>
> you would need code to iterate the nested array out again and
> process/validate the contents. If you are careful you could have
> multiple levels of nesting:-
>
> Eg.
>
> item => computer
> components=> array(
> CPU =>Intel Pentium 5 3.2ghz
> Case = Alien ATX
> Heatsink => BIG
> Memory => array(
> Type => Kinsgston 512 SDRAM
> qty => 2)
> )
>
> Obiron
>
> Neil Trigger wrote:
> > Hello!
> >
> > I'm new to this newsgroup, but not new to php. However I'm still having
a
> > bit of a problem and hope you can help.
> >
> > I wrote my own shopping cart script a while ago and now want to expant
upon
> > it by adding options to items if neccessary. These options would
determin
> > things like size, colour and materials of the items selected (it saves
the
> > shop database becomming too overloaded, and eases navigation for
clients).
> >
> > My question is this:
> > When adding items to a shopping cart, how do I record these advanced
> > options? I'm currently using the Welling & Thompson shopping cart
(modified
> > quite heavily). It uses the same method of putting items into a session
> > array, but I'm just wondering if I can add more details to the item.
> >
> > Some items have 1 set of options, some have none, some have lots.
Likewise
> > is there a way of defining items that are different sizes, shapes,
colours
> > etc. at the moment they're all bundled under "2 decks of cards" rather
than
> > 1 deck of poker sized red cards, 1 deck of bridge sized blue playing
cards.
> > Please visit
http://magic2k.com/shop/index.php?cat_open=&open=1&itemid=55
> > for an example.
> >
> > Hope this makes sense.
> >
> > Regards,
> >
> > --
> > Neil Trigger
> > Magic2k Manager
> > http://www.magic2k.com
> > http://www.oddmap.com
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация