[ic] Cart programming question

Ed LaFrance interchange-users@interchange.redhat.com
Thu Feb 14 14:46:00 2002


At 06:25 PM 02/14/2002 +0100, you wrote:
>Hi,
>
>... and my loved customers have a requirement.
>There are multiple (shop-) users organized in groups. Now it's
>possible that a user A saves a cart or a recurring order. Now it
>should made possible that a customer B (which is in the same
>group as user A) can get the carts A saved.
>
>Here I see two possibilities: I could make a page that loads the
>cart value from userdb from the other user (A), parse it in some
>way, and add the selected cart to the value in userdb for this
>user (B). The second possibility: I could add some new button
>which stores the contents of "uneval $Carts->{'main'}" into a
>database table (I would use my groups-table I think).
>
>         $cart_string = uneval $Carts->{'main'};
>         query "insert into group_carts ( content, group_id )
>                 VALUES ( $cart_string, $group_id )";
>         #   (or some Data-Tag instead of query)
>
>So far this shouldn't be a problem. For loading/getting, I think
>I just need somethink like
>
>
>         $db_field_content = query "select content from group_carts
>                 where group_id = $group_id
>                   and cart_id  = $cart_to_load";
>         #   (or some Data-Tag instead of query)
>         $Carts->{'main'} = eval $db_field_content;
>
>Now my questions:
>
>         - Is there a better third way to do it?
>
>         - Would method 2 work if I program a global user tag for
>           it (inside pages or catalog.cfg "eval" wouldn't work
>           beacuse of Safe, is this correct)?
>
>         - Is there a better way to "reload" this cart than with
>           eval?
>
>         - I never wrote into a table from IC. Do I have to expect
>           problems here (catalog.cfg permissions or similar)?
>
>         - Should I use another approach by editing UserDB.pm and
>           modify get_cart (and others) in a way, that they handle
>           group-assigned carts on this level?
>
>I don't have the right idea, since the cart functionality is part
>of the IC core and cannot be modified easily, so I would prefere
>method 2 (saving a uneval $Carts->{'main'}, and for reloading it
>doing a eval $field_content).
>
>Any suggestions? Thank you!
>
>oki,
>
>Steffen

Steffen - seems that you have thought about this a bit. FWIW, if I was 
tasked with doing this I would approach it with your otpion 2 idea.  the 
get_cart and set_cart routines in UserDB.pm should give you a pretty good 
guideline. Yes, I think it would have to be a global usertag due to Safe 
restrictions, but you may only need to have that tag stringify/unstringify 
the cart; data table reads and writes could be handled with ITL, i.e.:

[data base=groups_table field=cart key=group_id value="[stringify_cart 
cart=main]"]

- Ed L.


===============================================================
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          eCommerce | Consulting | Hosting
Placerville, CA  95667         edl@newmediaems.com
(530) 622-9421                 http://www.newmediaems.com
(866) 519-4680 Toll-Free       (530) 622-9426 Fax
===============================================================