[Catalyst] Catalyst + Class::Workflow
Matt Pitts
mpitts at a3its.com
Tue Feb 26 19:48:09 GMT 2008
> -----Original Message-----
> From: Christopher H. Laco [mailto:claco at chrislaco.com]
> Sent: Tuesday, February 26, 2008 2:05 PM
> To: The elegant MVC web framework
> Subject: [Catalyst] Catalyst + Class::Workflow
>
> Anyone done any integration with Class::Workflow and mapping object
> states to actions? I need to get back on the Mango wagon this week and
> I'm toying with making checkout nothing more than configurable states
> of an order.
>
> My first question is me wondering if checkout states are the same as
> order states, or if they should/could be two separate workflows.
I see them as separate workflows. When working on a site rebuild last year my boss and I addressed this question and we both agreed that a "cart" and an "order" are separate things. We drew the line at the point where a user enters billing information, but hasn't yet said "submit my order". This is the point at which we "copy" the cart into an order and tie them together.
> For example, once the customer places an order, we could have the
> following rather common order states:
>
> new
> processed
> authorized
> declined
> packed
> shipped
> refunded
> returned
> delivered
>
> During the checkout process, we have things like:
>
> initialized (create an order from cart)
> addressed (enter billto/shipto)
> shipmethod (selected ship method)
> preview
> submitted
>
> These can technically be states of the order preceding 'new', but I
> could also envision them as states of the checkout process itself and
> not necessarily states of the order itself.
>
> My other goal is to simply have /checkout/<state> be the uri structure
> for checkout, using transitions to kick off various plugins acting
> against the order.
>
> Thoughts? Anyone been down this road with Workflow in Catalyst?
Unfortunately no, but I think carts and workflows are a perfect fit. My controllers have built up too much control-flow logic because I can't do something as neat as...
sub auto : Private {
my ( $self, $c ) = @_;
if ( $c->cart_exists ) {
my $valid_action = '/checkout/' . $c->cart->state->stringify;
if ( $c->req->action ne $valid_action ) {
$c->res->redirect($c->uri_for($valid_action));
$c->detach;
}
}
else {
$c->flash->{alert} = "Your cart contains zero items, please buy something";
$c->res->redirect($c->uri_for('/store'));
$c->detach;
}
}
I have much less state-ful cart methods like...
$c->cart->is_empty
$c->cart->all_items_in_shipments
etc...
v/r
-matt pitts
More information about the Catalyst
mailing list