1 package BSE::Generate::Product;
3 use BSE::Generate::Article;
6 use base qw(BSE::Generate::Article);
7 use Constants qw(:shop $CGI_URI $ADMIN_URI);
10 use BSE::Util::Tags qw(tag_article);
12 our $VERSION = "1.001";
16 return "/cgi-bin/admin/add.pl?id=$id";
20 my ($self, $article, $articles) = @_;
22 my $product = Products->getByPkey($article->{id});
23 return $self->SUPER::generate($product, $articles);
27 my ($self, $product, $embedded) = @_;
32 <td><form action="$CGI_URI/admin/add.pl">
33 <input type=hidden name="edit" value=1>
34 <input type=hidden name=id value=$product->{id}>
35 <input type=submit value="Edit Product"></form></td>
36 <td><form action="$ADMIN_URI">
37 <input type=submit value="Admin menu">
39 <td><form action="$CGI_URI/admin/admin.pl" target="_blank">
40 <input type=submit value="Display">
41 <input type=hidden name=admin value=0>
42 <input type=hidden name=id value="$product->{id}"></form></td>
49 my ($self, $articles, $acts, $product, $embedded) = @_;
51 unless ($product->isa('Product')) {
52 $product = Products->getByPkey($product->{id});
55 my @stepcats = $product->step_parents();
57 my @options = $product->option_descs($self->{cfg});
62 $self->SUPER::baseActs($articles, $acts, $product, $embedded),
63 product=> [ \&tag_article, $product, $self->{cfg} ],
64 admin => [ tag_admin => $self, $product, 'product', $embedded ],
65 iterate_options_reset => sub { $option_index = -1 },
66 iterate_options => sub { ++$option_index < @options },
69 if ($_[0] eq 'popup') {
70 my $option = $options[$option_index];
73 -name => $option->{id},
75 -values => $option->{values},
78 push(@args, -labels=>$option->{labels}) if $option->{labels};
79 push(@args, -default=>$option->{default}) if $option->{default};
80 return BSE::Util::HTML::popup_menu(@args);
83 return escape_html($options[$option_index]{$_[0]})
86 ifOptions => sub { @options },
87 iterate_stepcats_reset => sub { $stepcat_index = -1 },
88 iterate_stepcats => sub { ++$stepcat_index < @stepcats },
89 stepcat => sub { tag_article($stepcats[$stepcat_index], $self->{cfg}, $_[0]) },
90 ifStepCats => sub { @stepcats },
95 my ($self, $article) = @_;
96 return $article->{listed};
99 sub get_real_article {
100 my ($self, $article) = @_;
102 return Products->getByPkey($article->{id});
111 BSE::Generate::Product - generates product detail pages for BSE
121 =item product I<field>
123 Access to product fields of the product being rendered. This is the
124 same as the C<article> I<field> tag for normal articles, but also give
125 you access to the product fields.
129 Produces product specific administration links in admin mode.
131 =item iterator ... options
133 Iterates over the options available for the product, setting the option tag.
137 The popup list of values for the current option.
141 Retrieves the given field from the option. Most commonly you just
145 <!-- you might want to start a table here -->
146 <:iterator begin options:>
147 <:option desc:>: <:option popup:>
148 <:iterator end options:>
149 <!-- and end a table here -->
150 <:or Options:><:eif Options:>
152 =item iterator ... stepcats
154 Iterates over any step parents of the product, setting the I<stepcat>
157 =item stepcat I<field>
159 Access to fields of the step catalogs of the parent.
163 Conditional tag, true if the product has any step catalogs.
167 =head2 Product specific fields
173 An in-between length description of the article for use on the catalog
178 The number of days it takes to receive the product after it has been
183 The cost to the customer of the product. You need to use the C<money>
184 tag to format this field for display.
188 Your cost. You need to use the C<money> tag to format this field for
193 The GST (in Australia) payable on the product.
197 The raw version of the options that can be set for this product.