[ic] How to retrieve item options data in a perl block
Joachim Schubert
as at freibergnet.de
Thu May 6 04:13:13 EDT 2004
Mike Heins wrote:
> Quoting Joachim Schubert (as at freibergnet.de):
> > Hi interchangers,
> >
> > this is IC 5.0* on FreeBSD with postgres.
> > I have some items with simple options
> > (new options: OptionsEnable option_type in etc/after.cfg).
> >
> > For further processing i would like to retrieve the selected
> > item options data from basket. In IC i have:
> > [item-list]
> > [item-options type=value report=1]
> > [/item-list]
> >
> > Now i don't now how to code this in a perl block / usertag.
> > Currently a use a scratch variable, but this isn't elegant.
> >
> > The following doesn't work as expected:
> >
> > [calc]
> > my $out;
> > my $cart = $Carts->{main};
> > my %options = (report => '1', type => 'value');
> > my $opt = \%options;
> > foreach my $item (@$cart) {
> > $out .= $item->{code} ."-";
> > $out .= $item->{quantity} ."-";
> > $out .= $Tag->options( $item->{code},
> > undef,
> > $opt,
> > $item, );
> >
> > $out .= "<br>";
> > }
> > return $out;
> > [/calc]
> >
> > The options-tag returns html form fields, but i need the data like
> > optionname: optionvalue. How can a get these options-data?
>
> Each option is represented in the item hash. Since you are already
> in the cart:
>
> my @out;
> foreach my $item (@$cart) {
> my @keys = keys %$item;
> @keys = grep $_ !~ /^mv_/, @keys;
> for (sort @keys) {
> push @out, "$_: $item->{$_}";
> }
> push @out, '';
> }
>
> return join "<br>", @out;
>
This works very well, thank you Mike
Achim
> --
> Mike Heins
> Perusion -- Expert Interchange Consulting http://www.perusion.com/
> phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
>
> Fast, reliable, cheap. Pick two and we'll talk. -- unknown
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
--
L&P::Kommunikation GbR im Geschäftsbereich
FreibergNet.de Internet Systems Joachim Schubert
D-09599 Freiberg Phone (+49) 03731/41 93 26
Nonnengasse 31a Fax (+49) 03731/41 93 17
More information about the interchange-users
mailing list