call price in scalar context when building cart item hash
[bse.git] / site / cgi-bin / modules / BSE / TB / OrderItem.pm
CommitLineData
0ec4ac8a
TC
1package BSE::TB::OrderItem;
2use strict;
3# represents an order line item from the database
4use Squirrel::Row;
5use vars qw/@ISA/;
6@ISA = qw/Squirrel::Row/;
7
cb7fd78d
TC
8our $VERSION = "1.000";
9
0ec4ac8a
TC
10sub columns {
11 return qw/id productId orderId units price wholesalePrice gst options
12 customInt1 customInt2 customInt3 customStr1 customStr2 customStr3
7b4490e1 13 title description subscription_id subscription_period max_lapsed
74b21f6d 14 session_id product_code/;
0ec4ac8a
TC
15}
16
14604ada
TC
17sub defaults {
18 return
19 (
20 units => 1,
21 options => '',
22 customInt1 => undef,
23 customInt2 => undef,
24 customInt3 => undef,
25 customStr1 => undef,
26 customStr2 => undef,
27 customStr3 => undef,
28 );
29}
30
58baa27b
TC
31sub option_list {
32 my ($self) = @_;
33
34 require BSE::TB::OrderItemOptions;
35 return sort { $a->{display_order} <=> $b->{display_order} }
36 BSE::TB::OrderItemOptions->getBy(order_item_id => $self->{id});
37}
38
13a986ee
TC
39sub product {
40 my ($self) = @_;
41
42 $self->productId == -1
43 and return;
44 require Products;
45 return Products->getByPkey($self->productId);
46}
47
0ec4ac8a 481;