Building E-Commerce Sites with Handel
by Christopher H. Laco
|
Pages: 1, 2, 3, 4, 5
Checkout
On the cart page, hit the Checkout button. This will take you to the BillTo/ShipTo edit screen (Figure 6).

Figure 6. The BillTo/ShipTo page
In either of the first name fields, enter your first name. Scroll to the bottom of the page and click Continue. If everything is working correctly, you should see a page resembling Figure 7.

Figure 7. An error in billing/shipping
Once again, the generated code from Handel has taken care of validating required form fields for you and the fill-in forms kept the data you entered, all without writing any code. (Noticing a theme yet?)
Take some time on your own to work your way through the rest of the checkout process. This includes a preview page, the credit card payment page, and an order completion page. Once you've completed your order, you should receive a "thank you" page with links to view all of your orders (Figure 8).

Figure 8. The Order Complete page
Orders List
Last but not least, check out the orders list. On your order completion screen, click on the View Orders link. Here you will find a list of any orders you have placed (Figure 9). Click the View Order link next to any order for more details about that order (Figure 10).

Figure 9. The Orders List page.

Figure 10. The order details page
Where To Go From Here
As you've hopefully seen in the article, by combining the powers of Handel and Catalyst, you need not suffer through the dreary task of writing another shopping cart from scratch ever again. With the plugin architecture Handel provides, you will find that you can do even the more complicated checkout tasks using nothing more than a few lines of code to glue various business modules into plugins.
With Handel as the core, we can look forward to new and improved Perl-based E-commerce solutions and new ways to add E-commerce features to existing projects without having to reinvent the wheel--again!
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 18 of 18.
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
2008-02-26 00:16:29 LakeTahoe [Reply]
I am having trouble resolving this error. Which package is needed to handle sessions?
Thanks
Joel- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
2008-02-26 05:41:09 claco [Reply]
You don't have the Session plugins loaded.
http://search.cpan.org/~claco/Handel-1.00006/lib/Handel/Manual/QuickStart.pod#NEW_CATALYST_APPLICATIONS
https://rt.cpan.org/Ticket/Display.html?id=31166- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
2008-02-26 11:15:27 LakeTahoe [Reply]
Thank you for the reply. I am obviously new with this package, but I thought I read that Catalyst would automatically load the appropriate plugins. This does not seem to working.
[debug] Loaded plugins:
.----------------------------------------------------------------------------.
| Catalyst::Plugin::ConfigLoader 0.19 |
| Catalyst::Plugin::Static::Simple 0.20 |
'----------------------------------------------------------------------------'
Request
bless({
action => "cart/add",
address => "67.47.131.143",
arguments => [],
base => bless(do{\(my $o = "http://tahoestores.org:3000/")}, "URI::http"),
body_parameters => {
description => "Mendlefarg 3000",
price => "19.95",
quantity => 1,
sku => "MFG3000",
},
captures => [],
cookies => {},
headers => bless({
"accept" => "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
"accept-charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"accept-encoding" => "gzip,deflate",
"accept-language" => "en-us,en;q=0.5",
"cache-control" => "max-age=0",
connection => "keep-alive",
"content-length" => 62,
"content-type" => "application/x-www-form-urlencoded",
host => "tahoestores.org:3000",
"keep-alive" => 300,
referer => "http://tahoestores.org/cart.html",
"user-agent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12",
}, "HTTP::Headers"),
hostname => "dpc6747131143.direcpc.com",
match => "cart/add",
method => "POST",
parameters => {
description => "Mendlefarg 3000",
price => "19.95",
quantity => 1,
sku => "MFG3000",
},
path => "cart/add",
protocol => "HTTP/1.0",
query_parameters => {},
secure => 0,
uploads => {},
uri => bless(do{\(my $o = "http://tahoestores.org:3000/cart/add")}, "URI::http"),
user => undef,
}, "Catalyst::Request")
Response
bless({
body => "",
cookies => {},
headers => bless({
"content-type" => "text/html; charset=utf-8",
"x-catalyst" => "5.7012",
}, "HTTP::Headers"),
status => 200,
}, "Catalyst::Response")
Stash
{}
Config
do {
my $a = {
"Plugin::ConfigLoader" => {},
debug => {
ignore_classes => [
"DBIx::Class::ResultSource::Table",
"DBIx::Class::ResultSourceHandle",
"DateTime",
],
scrubber_func => sub { "???" },
},
home => "/usr/local/www/apache22/cgi-bin/MyStore",
name => "MyStore",
root => bless({
dirs => ["", "usr", "local", "www", "apache22", "cgi-bin", "MyStore", "root"],
file_spec_class => undef,
volume => "",
}, "Path::Class::Dir"),
static => {
debug => 1,
dirs => [],
ignore_dirs => [],
ignore_extensions => ["tmpl", "tt", "tt2", "html", "xhtml"],
include_path => ['fix'],
mime_types => {},
mime_types_obj => bless({}, "MIME::Types"),
no_logs => 1,
},
};
$a->{static}{include_path}[0] = $a->{root};
$a;
}
Is there something I am missing?
Thanks
Joel
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
2008-02-26 11:25:47 claco [Reply]
http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-0.19/lib/Catalyst/Plugin/Session/Tutorial.pod#Configuration
You don't appear to be loading the Session plugins at all.
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
2008-02-26 18:12:48 LakeTahoe [Reply]
Thanks, I did not realize that I would have to edit MyStore.pm to specify the plugins in your example.
Once I located the proper use statement and added Session everything appears to be working on FreeBSD.
Joel
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
- Caught exception in MyStore::Controller::Cart->create "Can't locate object method "session" via package "MyStore"
- Couldn't render template "file error - cart/add: not found"
2006-04-11 20:58:31 Xersmith [Reply]
This error just pops out after I add to the cart? I'm trying to direct the view class to the path of the templates but it nothing happened. Can anyone share light on this?- Couldn't render template "file error - cart/add: not found"
2006-04-12 04:41:09 claco [Reply]
Are you using the latest version of Catalyst? This article was written well before the current version of Catalyst (5.66). I suspect that the problem is either the extensions, or changes in the the uri_for that are causing the problem.
To make sure the TT view is looking for .tt files, see http://search.cpan.org/~mramberg/Catalyst-View-TT-0.22/lib/Catalyst/View/TT.pm#___top for the changes to make to config.
If you're still having problems, feel free to contact me at claco@chrislaco.com, and I'm usually on the #catalyst and #handel channels on irc.perl.org.
- Couldn't render template "file error - cart/add: not found"
- Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db...
2006-04-05 20:48:48 gennoob [Reply]
Hi, I'm a noob programmer on Perl and I've been asked to work with Catalyst as well, so I've been checking out examples. Anyway, I followed your instructions but in the end I have this error message:
Caught exception in MyStore::Controller::Cart->begin "Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db, no database driver specified and DBI_DSN env var not set at /usr/lib/perl5/site_perl/5.8.7/Ima/DBI.pm line 312"
I know Ima::DBI is not part of your instructions and not a prerequisite of any packages you mentioned. I think it was already here even before I was assigned to this machine (the previous programmer who worked with this machine had a lot of packages installed). Could you help me with this?- Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db...
2006-04-06 09:30:13 claco [Reply]
Let's start from the top and see if we can find something.
What OS is this on?
What version of sqlite is installed? Run:
$ sqlite -version
or
$ sqlite3 -version
What version of DBI is installed? Run:
$perl -MDBI -e 'print DBI->VERSION;"
What version of Ima::DBI is installed?
$perl -MIma::DBI -e 'print Ima::DBI->VERSION;"
What version of Catalyst is installed?
$perl -MCatalyst -e 'print Catalyst->VERSION;"
What version of Handel in installed?
$perl -MHandel -e 'print Handel->VERSION;"
In the Cart model that was created during the top part of Page 3 of the
article (created
"/usr/home/claco/MyStore/script/../lib/MyStore/M/Cart.pm"), what does
the contents of that file look like?
-=Chris- Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db...
2006-04-10 20:50:18 gennoob [Reply]
Hi! Sorry for not replying. Anyway, I've found the problem. An extra space was generated by the use of the slash(\) when specifying the database. Removed the space and got it working. ^^
- Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db...
- Can't connect to data source dbi:SQLite:dbname=/home/jdc/handel.db...
- Great !!! We need a FreeBSD port soon !!!
2005-12-14 07:39:49 maxpaz [Reply]
I hope to find soon a Handel port in the FreeBSD packages.- Great !!! We need a FreeBSD port soon !!!
2005-12-14 08:43:20 claco [Reply]
I use FreeBSD on the servers at home, but I've never tried making a port from scratch.
As I do most of my CPAN installs through CPAN/CPANPLUS, or manually, what would the benifit of a FreeBSD port be?
- Great !!! We need a FreeBSD port soon !!!
- Great Article
2005-11-22 20:30:01 beachguy82 [Reply]
Untill a book comes out about catalyst and it's many plugins, we need all the articles we can get!
- Error message after following destructions :-)
2005-11-17 20:35:07 _aj [Reply]
Caught exception "Can't locate object method "uuid" via package "MyStore::M::Cart" (perhaps you forgot to load "MyStore::M::Cart"?) at /home/admin/shop/MyStore/script/../lib/MyStore/Controller/Cart.pm line 194."- Error message after following destructions :-)
2005-11-18 05:52:28 claco [Reply]
This is due to a change in Catalyst 5.5, which was released after this article was written.
Catalyst now defaults to using long names for modules; Model instead of M, View instead of V, and Controller instead of C when creating modules.
I need to review the article using 5.5 and post any changes. in the mean time, I believe creating the ap on page 1 using:
catalyst.pl -short MyStore
instead of
catalyst.pl MyStore
should fix your problem.
- Error message after following destructions :-)
2005-11-21 02:01:49 HarryF [Reply]
Tried using the -short flag - no luck.
Ended up fixing with some search and replace;
Look in MyStore/Controllers - in all three of the Perl modules created here, replace "::M::" with "::Model::" and "::V::" with "::View::"- Error message after following destructions :-)
2005-11-21 06:18:43 claco [Reply]
Sorry about that. This is something I missed in the earlier comments about the -short option in Catalyst 5.5.
It appears that you need to use the -short option in both catalyst.pl and the create.pl scripts under Catalyst 5.5+.
When creating the app, use:
$ catalyst.pl -short MyStore
When creating the scaffolding, use:
$ script/mystore_create.pl -short Handel::Scaffold
dbi:SQLite:dbname=/home/claco/handel.db
This will create the Handel components using the short name. I mistakenly thought that create.pl would remember that the app was created using -short in catalyst.pl and do the same thing. Obviously not.
I'm working on 0.28 which uses the new model()/view()/controller() shortcuts in 5.5 to better avoid this kind of problem.- Error message after following destructions :-)
2005-11-21 18:39:18 garyaj1 [Reply]
I also had installed Cat 5.5 and got the same error message so I manually changed ::[MVC]:: to corresponding long names. But I then got the same error message (i.e. 'missing uuid') and, sure enough, I had not installed Data::UUID which is mentioned in the Handel POD page but not in your article. (I don't know how cpanp could install Handel without complaining about missing Data::UUID.)
Anyway it works now. Great article and package.
- Error message after following destructions :-)
- Error message after following destructions :-)
- Error message after following destructions :-)
- Error message after following destructions :-)



