[Handel] subclassing Handel::Order in Catalyst

Ryan Lauterbach ryan at radianit.com
Tue Oct 10 01:37:25 CEST 2006


I have successfully subclassed Handel::Cart and Handel::Cart::Items in 
.99_14 to add extra fields in cart_items.  Now i need to copy the 
cart_items fields over to order_items upon checkout.  I believe I need 
to override copy_cart_items per the Handel::Order POD so here are my 
classes which don't work.  Thanks for looking:

package RMA::M::Order;
use strict;
use warnings;

    use base qw/Catalyst::Model::Handel::Order/;

    connection_info => ['dbi:mysql:db', 'dbuser', 'dbpass'],
    order_class => 'RMA::M::HandelOrder',

package RMA::M::HandelOrder;
use strict;
use warnings;
use base qw/Handel::Order/;


sub copy_cart_items {
    my ($self, $order, $cart) = @_;
    my $items;

        no strict 'subs';
        $items = $cart->items(undef, RETURNAS_ITERATOR);

    while (my $item = $items->next) {
        my %copy;

        foreach (RMA::M::HandelItem->columns) {
            next if $_ =~ /^(id|cart)$/i;
            $copy{$_} = $item->$_;

        $copy{'id'} = $self->uuid unless constraint_uuid($copy{'id'});
        $copy{'orderid'} = $order->id;
        $copy{'total'} = $copy{'quantity'}*$copy{'price'};

        $copy{logo} = 'logotest';



package RMA::M::HandelCart;
use strict;
use warnings;
use base qw/Handel::Cart/;



package RMA::M::HandelItem;

use strict;
use warnings;
use base qw/Handel::Cart::Item/;

__PACKAGE__->storage->add_columns(qw/logo logo_data logo_type photo_type 
photo_data photo c .../


More information about the Handel mailing list