[interchange-cvs] interchange - heins modified 2 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Thu Jan 31 11:04:01 2002
User: heins
Date: 2002-01-31 16:03:41 GMT
Modified: lib/Vend Form.pm Interpolate.pm
Log:
* Changes to make [item-accessories ...] and [item-options ...] work on
flypage/loop as well as in cart.
* Fix dropdown/select defaults applied with asterisk.
* Fix price data insert for [item-options].
Revision Changes Path
2.3 +17 -5 interchange/lib/Vend/Form.pm
rev 2.3, prev_rev 2.2
Index: Form.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Form.pm,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -r2.2 -r2.3
--- Form.pm 31 Jan 2002 15:17:34 -0000 2.2
+++ Form.pm 31 Jan 2002 16:03:41 -0000 2.3
@@ -1,6 +1,6 @@
# Vend::Form - Generate Form widgets
#
-# $Id: Form.pm,v 2.2 2002/01/31 15:17:34 mheins Exp $
+# $Id: Form.pm,v 2.3 2002/01/31 16:03:41 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -36,7 +36,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.2 $, 10);
+$VERSION = substr(q$Revision: 2.3 $, 10);
@EXPORT = qw (
display
@@ -370,7 +370,7 @@
sub dropdown {
my($opt, $opts) = @_;
-::logDebug("called select opt=" . ::uneval($opt) . "\nopts=" . ::uneval($opts));
+#::logDebug("called select opt=" . ::uneval($opt) . "\nopts=" . ::uneval($opts));
my $price = $opt->{price} || {};
@@ -423,7 +423,14 @@
}
$run .= '<option';
$select = '';
- s/\*$// and $select = 1;
+
+ if($label) {
+ $label =~ s/\*$// and $select = 1;
+ }
+ else {
+ $value =~ s/\*$// and $select = 1;
+ }
+
if ($default) {
$select = '';
}
@@ -664,6 +671,7 @@
my $ishash;
if(ref ($item) eq 'HASH') {
+#::logDebug("item=$item");
$ishash = 1;
}
else {
@@ -750,15 +758,19 @@
my $adder;
$adder = $item->{mv_ip} if defined $item->{mv_ip}
and $opt->{item} || ! $opt->{name};
+ $opt->{name} = $opt->{attribute}
+ unless $opt->{name};
$opt->{value} = $item->{$opt->{attribute} || $opt->{name}};
- $opt->{name} = $opt->{attribute} unless $opt->{name};
$opt->{name} .= $adder if defined $adder;
- $opt->{price} = get_option_hash($opt->{price_data}) if $opt->{price};
-#::logDebug("tag_accessories: name=$name");
+#::logDebug("tag_accessories: name=$opt->{name} ISHASH");
}
else {
+#::logDebug("display: name=$opt->{name} IS NOT HASH");
$opt->{name} = "mv_order_$opt->{attribute}" unless $opt->{name};
}
+
+ $opt->{price} = get_option_hash($opt->{price_data})
+ if $opt->{price};
$opt->{name} ||= $opt->{attribute};
if(defined $opt->{value}) {
2.46 +3 -5 interchange/lib/Vend/Interpolate.pm
rev 2.46, prev_rev 2.45
Index: Interpolate.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.45
retrieving revision 2.46
diff -u -r2.45 -r2.46
--- Interpolate.pm 31 Jan 2002 14:58:41 -0000 2.45
+++ Interpolate.pm 31 Jan 2002 16:03:41 -0000 2.46
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.45 2002/01/31 14:58:41 mheins Exp $
+# $Id: Interpolate.pm,v 2.46 2002/01/31 16:03:41 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -27,7 +27,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.45 $, 10);
+$VERSION = substr(q$Revision: 2.46 $, 10);
@EXPORT = qw (
@@ -1977,7 +1977,7 @@
push @rf, ($map{$_} || $_);
}
my @def;
- if($item->{code}) {
+ if($item and $item->{code}) {
@def = split /-/, $item->{code};
}
my $fsel = $map{sku} || 'sku';
@@ -1990,7 +1990,7 @@
my $ary = $db->query($q);
my $ref;
my $i = 0;
- my $phony = { %$item };
+ my $phony = { %{$item || { }} };
foreach $ref (@$ary) {
next unless $ref->[3];
@@ -2192,9 +2192,6 @@
#::logDebug("tag_accessories: item is a hash");
$ishash = 1;
}
- else {
- $item = {};
- }
# Had extra if got here
#::logDebug("tag_accessories: code=$code opt=" . ::uneval_it($opt) . " item=" . ::uneval_it($item) . " extra=$extra");
@@ -2212,6 +2209,7 @@
return Vend::Form::display($opt, $item)
if $::Variable->{MV_DANGEROUS_NEW_FORM}
or $Global::Variable->{MV_DANGEROUS_NEW_FORM};
+ $item ||= {};
my $p = $opt->{prepend} || '';
my $a = $opt->{append} || '';
my $delimiter = $opt->{delimiter} || ',';