[Handel] shopping cart

Jan Gerene jan at gerene.be
Thu Aug 3 16:58:01 CEST 2006


Op donderdag 03 augustus 2006 16:39, schreef Christopher H. Laco:

> You can always do this in your script:
>
> if ( my $item = $cart->items({sku => 'ABC123'}) ) {
>     print "Item Exists";
> } else {
>    $cart->add({sku => 'ABC123'});
> };
>
> or subclass:
>
> package CustomCart;
> use base qw/Handel::Cart/;
>
> sub add {
>     my ($self, $data) = @_;
>
>     if ( my $item = $cart->items({sku => $data->{'sku'}}, 1)->first ) {
> 	$item->quantity($item->quantity + 1);
>     } else {
>         return $cart->add({sku => 'ABC123'});
>     };
> };
>
> 1;

Thanks for this code, I will certainly look at it.

>
> I assume you're working with Handel 0.33? I would also suggest taking a
> look at the 0.99_04 version on CPAN. 1.0 should be out sometime soon,
> and it is a major redesign.
>
Yes, I am using Handel 0.33, I tried using 099_02 a while ago, but couldn't 
compile it.  You did recommend me to stick with 0.33 at that time.
Do you think that using 0.99 would be appropriate now?

-- 
Jan Gerene
Heikant 99
2560 Bevel
gsm: +32-475406294
tel: +32-32191252



More information about the Handel mailing list