[Handel] shopping cart

Christopher H. Laco claco at chrislaco.com
Thu Aug 3 17:00:03 CEST 2006


Jan Gerene wrote:
> 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?
> 

Not yet. I would just keep an eye on it in case there are any big API
changes to be aware of.

-=Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/handel/attachments/20060803/8fcb3c1e/attachment.pgp 


More information about the Handel mailing list