[Handel] subclassing Handel::Order in Catalyst

Ryan Lauterbach ryan at radianit.com
Sat Oct 21 18:03:37 CEST 2006


Christopher H. Laco wrote:
> Ryan Lauterbach wrote:
>   
>> Christopher H. Laco wrote:
>>     
>>> Ryan Lauterbach wrote:
>>>   
>>>       
>>>> Yaaaa, its working!
>>>>     
>>>>         
>> Ok maybe that was a bit premature, but its close now, really!
>>
>> When i go to checkout, the orders.total and orders.tax fields aren't 
>> updated.  The order_items table has the price and total fields updated 
>> ok.  Now i can understand the tax being empty as I haven't set this 
>> anywhere.  What is the preferred method for doing this.  I read 
>> something about default_values->() somewhere but is that what I should 
>> be using?   I was thinking I needed to load a plugin (like I did with 
>> AssignOrderNumber) to update orders.total but I figured that wouldn't be 
>> the case.  At what point in the pipeline (CHECKOUT_PHASE_FINALIZE) would 
>> these values be set?   Maybe there is an error with my subclassing below?
>>
>> Thanks for any hints!
>>     
>
> Define "when I go to checkout"... for the first time?
> After updated the cart, and returning? The the bill/ship info? To the
> payment info?
>   
I'm using the default catalyst controllers created with the Handel 
helper.  When viewing the cart I click checkout which posts to 
/check/billing
> There are a few ways to go about the order totals...it depends on when
> you expect it to be set and when.
>
> I would think that the order.total field will always be empty until
> after tax, shipping, etc is  calculated...but before any
> authorization...so the FINALIZE phase would be too late...
>
> The short answer is, you can do it whenever you want...
> You could tweak the billing() Controller method to cal totals on post...
>
> Or, you could add a checkout plugin for the VALIDATE phase and cal
> totals in there...(which is run during the bill to/ship to updates...
>
> Or, you could add a phase between VALIDATE and AUTHORIZE, and add a
> plugin in there...
>
> It's up to you really...just a bunch of building blocks...
>
> -=Chris
>
>   
Ahh ok.   I've just done

                my $order_total = 0;
                for my $item ($order->items) {
                    $order_total += $item->total;
                }
                $order->total($order_total);

after  CHECKOUT_PHASE_VALIDATE, which works, although not very slick.   
It would be good to see a full blown Handel app to see some examples 
that "do the right thing", or better utilize the framework Chris has 
engineered.   There are a lot of building blocks available in Handel and 
I know I'm only using a fraction of them.  Actually, Mango might be the 
answer to that, eh?

Thanks again Chris.




More information about the Handel mailing list