1 package Generate::Product;
6 use base qw(Generate::Article);
7 use Constants qw(:shop $CGI_URI $ADMIN_URI);
13 return "/cgi-bin/admin/add.pl?id=$id";
17 my ($self, $article, $articles) = @_;
19 my $product = Products->getByPkey($article->{id});
20 return $self->SUPER::generate($product, $articles);
24 my ($self, $product, $embedded) = @_;
29 <td><form action="$CGI_URI/admin/add.pl">
30 <input type=hidden name="edit" value=1>
31 <input type=hidden name=id value=$product->{id}>
32 <input type=submit value="Edit Product"></form></td>
33 <td><form action="$ADMIN_URI">
34 <input type=submit value="Admin menu">
36 <td><form action="$CGI_URI/admin/admin.pl" target="_blank">
37 <input type=submit value="Display">
38 <input type=hidden name=admin value=0>
39 <input type=hidden name=id value="$product->{id}"></form></td>
46 my ($self, $articles, $acts, $product, $embedded) = @_;
48 unless ($product->isa('Product')) {
49 $product = Products->getByPkey($product->{id});
52 my @stepcats = $product->step_parents();
55 map { +{ id=>$_, %{$SHOP_PRODUCT_OPTS{$_}} } }
56 grep $SHOP_PRODUCT_OPTS{$_},
57 split /,/, $product->{options};
62 $self->SUPER::baseActs($articles, $acts, $product, $embedded),
63 product=> sub { escape_html($product->{$_[0]}) },
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},
74 -values => $option->{values},
77 push(@args, -labels=>$option->{labels}) if $option->{labels};
78 push(@args, -default=>$option->{default}) if $option->{default};
79 return DevHelp::HTML::popup_menu(@args);
82 return escape_html($options[$option_index]{$_[0]})
85 ifOptions => sub { @options },
86 iterate_stepcats_reset => sub { $stepcat_index = -1 },
87 iterate_stepcats => sub { ++$stepcat_index < @stepcats },
88 stepcat => sub { escape_html($stepcats[$stepcat_index]{$_[0]}) },
89 ifStepCats => sub { @stepcats },
94 my ($self, $article) = @_;
95 return $article->{listed};
104 Generate::Product - generates product detail pages for BSE
114 =item product I<field>
116 Access to product fields of the product being rendered. This is the
117 same as the C<article> I<field> tag for normal articles, but also give
118 you access to the product fields.
122 Produces product specific administration links in admin mode.
124 =item iterator ... options
126 Iterates over the options available for the product, setting the option tag.
130 The popup list of values for the current option.
134 Retrieves the given field from the option. Most commonly you just
138 <!-- you might want to start a table here -->
139 <:iterator begin options:>
140 <:option desc:>: <:option popup:>
141 <:iterator end options:>
142 <!-- and end a table here -->
143 <:or Options:><:eif Options:>
145 =item iterator ... stepcats
147 Iterates over any step parents of the product, setting the I<stepcat>
150 =item stepcat I<field>
152 Access to fields of the step catalogs of the parent.
156 Conditional tag, true if the product has any step catalogs.
160 =head2 Product specific fields
166 An in-between length description of the article for use on the catalog
171 The number of days it takes to receive the product after it has been
176 The cost to the customer of the product. You need to use the C<money>
177 tag to format this field for display.
181 Your cost. You need to use the C<money> tag to format this field for
186 The GST (in Australia) payable on the product.
190 The raw version of the options that can be set for this product.