[ic] Wierdness with AutoLoad And Item Actions, Possible Bug

Shawn Mathews shawn at stuckinrealtime.us
Fri Apr 23 10:11:06 EDT 2004


I'm getting some weird results under ic 5.01 when I use AutoLoad along 
with item actions.

I'll explain the setup.... (code follows at end of message)

#1) I'm using Matrix Options. The rules for my client are that only 
variant items can be ordered not the base item. Only one Variant for any 
  base item can be purchased.

ie. XYZ = Base Product , XYZ-01 thru XYZ-06 are the variants.

#2)I have a global sub defined in my interchange.cfg which I reference 
for the different item actions.

#3)I use an AutoLoad Globalsub which does a few things for our affiliate 
system. (setting initial referer, etc)

Now The Problem

If I referernce my Autoload as a global sub, I get an error when I add 
items to the cart which have an item action associated with them.

[22/April/2004:19:05:06 -0400] oldvprx /oldvprx/ord/basket.html 
Undefined subroutine &Vend::Interpolate::eye5_singleitem called at (eval 
371) line 4.

If I insert the AutoLoad code into the catalog.cfg using heredoc syntax 
  and [perl] ... [/perl] I get the same error.

The error stops if I use [perl global=1 subs=1] ... [/perl]

Any Ideas why this would be happening?

Thanks,
Shawn Mathews

-- BEGIN CODE --

==> Interchange.cfg
GlobalSub <<EOR
sub eye5_noorder {
     my $item = shift;
     $item->{'quantity'} = 0;
}
EOR

GlobalSub <<EOR
sub eye5_singleitem {
     my $item = shift;
     my $retoss = undef;
     return if $item->{quantity} == 0; # Don't Need To Run if We Are 
Deleting the Item
     return if (defined $item->{mv_ip}); # Don't Run If Item isn't being 
added to the cart
     return if ($item->{mv_sku} =~ /^FREE/i);
     my $cart = $Vend::Items;
     my $i = 0; # Need an index to update the master list
     foreach my $chkitem (@$cart) {
         if (($chkitem->{'mv_sku'} !~ /^FREE/i) && ($chkitem->{'code'} 
!~ /^FREE/)) {
         if (($chkitem->{'mv_sku'} eq $item->{'mv_sku'}) && 
($chkitem->{'code'} ne $item->{'code'}) &&($chkitem->{'quantity'} != 0)) {
           ::logDebug('Removing: '.$chkitem->{'code'});
           $Vend::Items->[$i]->{'quantity'} = 0;
           $retoss = 'RETOSS';
         }
         }
         $i++;
     }
}
EOR

GlobalSub <<EOR
sub e5_autoload {
     my $wc = $::Variable->{'PARTNERSOFTID'};
     my $override = $::Variable->{'OVERRIDE_AFFILIATE_FLAG'};

     # Initialize Our Page Count
     if((!defined $::Session->{$wc.'_pagecount'}) || 
($::Session->{$wc.'_pagecount'} < 0)) {
         $Vend::Session->{$wc.'_pagecount'} = 0;
     }
     $::Session->{$wc.'_pagecount'} ||= 0;
     if((!defined $::Session->{'pagecount'}) || 
($::Session->{'pagecount'} < 0)) {
        $Vend::Session->{'pagecount'} = 0;
     }
     my $advertid = $::Session->{'source'};
     if ((!defined $advertid) || ($advertid eq '')) {
         $advertid = 'NoAdvert';
     }
     my $e5_advert = $::Session->{'eyefive_advertid'};
     if ((!defined $e5_advert) || ($e5_advert eq '') || ($e5_advert eq 
'NoAdvert')) {
         $e5_advert = $::Session->{'source'};
         $e5_advert ||= 'NoAdvert';
     }



     # Don't update AdvertID if it's already defined
     if ($::Session->{'pagecount'} == 0) { # This is the first hit
         $::Session->{'source'} = $advertid;
         $::Session->{'eyefive_advertid'} = $advertid;
     } else {
         if ($e5_advert ne 'NoAdvert') {
           $::Session->{'source'} = $e5_advert;
         }
     }

# Add Referer Stuff
     my $ref = $::Session->{'eyefive_referer'};
     if ((!defined $ref) || ($ref eq 'NoReferer')) {
           my $referer;
           my $referer = $::CGI->{'r'} if defined $::CGI->{'r'};
           $referer ||= $ref if ((defined $ref) && ($ref ne 'NoReferer'));
           $referer ||= $::ENV{'HTTP_REFERER'};
           $referer ||= 'NoReferer';
           $::Session->{'eyefive_referer'} = $referer;
     }


     if ($override eq 'Y') {
         my $tmp_aff = $::Variable->{'OVERRIDE_AFFILIATE_NAME'};
         $::Session->{'eyefive_advertid'} = $tmp_aff;
         $::Session->{'source'} = $tmp_aff;
     }

     # Get Campaign if Defined
     my $cmp = $::CGI->{'cmp'};
     $cmp ||= $::Session->{'eyefive_campaign'};
     $cmp ||= 'DEFAULT';
     $::Session->{'eyefive_campaign'} = $cmp;

     $::Session->{'advertid'} = $::Session->{'source'};

}
EOR

==> catalog.cfg
ItemAction XYZ eye5_noorder
ItemAction XYZ-01 eye5_singleitem
ItemAction XYZ-02 eye5_singleitem
ItemAction XYZ-03 eye5_singleitem




More information about the interchange-users mailing list