Interchange Upgrade Guide



Table of Contents


1. Introduction

This document contains, in rough form, notes on upgrading from Minivend 3 to Minivend 4, and Minivend 4 to Interchange.


2. Interchange 4.8 Deprecated Features

This document describes features of Interchange 4.8 that have been deprecated. Any use of these features should be discontinued. In most cases we have provided an alternative mechanism to accomplish the same results. These deprecated features may be removed at some point in the future. You should change to the new mechanism to avoid breakage.

2.1. Deprecated Features Previous to Interchange 4

This section needs some serious work.

cart/page from path

            if($path =~ s:/(.*)::) {
                    $cart = $1;
                    if($cart =~ s:/(.*)::) {
                            $page = $1;
                    }
            }

mv_orderpage

            $CGI::values{mv_nextpage} = $CGI::values{mv_orderpage}
                                                                    || find_special_page('order')
                    if ! $CGI::values{mv_nextpage};

$decode

                            HTML::Entities::decode($value) if $decode;

mv_orderpage

                                            $CGI::values{mv_nextpage} = $CGI::values{mv_orderpage}
                                                    if $CGI::values{mv_orderpage};

ROUTINES and LANG

            ROUTINES: {
                    last ROUTINES unless index($Vend::FinalPath, '/process/') == 0;
                    while ($Vend::FinalPath =~ s:/process/(locale|language|currency)/([^/]*)/:/process/:) {
                            $::Scratch->{"mv_$1"} = $2;
                    }
                    $Vend::FinalPath =~ s:/process/page/:/:;
            }
            my $locale;
            if($locale = $::Scratch->{mv_language}) {
                    $Global::Variable->{LANG}
                            = $::Variable->{LANG} = $locale;
            }
    
            if ($Vend::Cfg->{Locale}                                                                and
                    $locale = $::Scratch->{mv_locale}       and
                    defined $Vend::Cfg->{Locale_repository}->{$locale}
                    )
            {
                    $Global::Variable->{LANG}
                                    = $::Variable->{LANG}
                                    = $::Scratch->{mv_language}
                                    = $locale
                             if ! $::Scratch->{mv_language};
                    Vend::Util::setlocale(  $locale,
                                                                    ($::Scratch->{mv_currency} || undef),
                                                                    { persist => 1 }                                                        );
            }

list_compat

            list_compat($opt->{prefix}, \$text);
            list_compat($opt->{prefix}, \$text);
            list_compat($opt->{prefix}, \$page);

find_sort

            $text =~ /^\s*\[sort\s+.*/si
                    and $opt->{sort} = find_sort(\$text);

mv_order_report

        $body = readin($::Values->{mv_order_report})
                    if $::Values->{mv_order_report};

mv_error_$var

                            $::Values->{"mv_error_$var"} = $message;

2.2. Interchange 4 Deprecated Features

Vend::Util::send_mail Vend::Order::send_mail send_mail


3. Upgrading from Minivend 4.0 to Interchange 4.6

3.1. minivend.cfg

3.2. Access Manager

    groups
    last_login
    name
    password
            Variable            MINIMATE_META   mv_metadata
            Variable            MINIMATE_TABLE  minimate
            Database            minimate        minimate.asc      TAB
            Database            affiliate    affiliate.txt     TAB

3.3. Database Editing

3.4. Order Manager

        affiliate  approx. char(32)
        archived   char(1)
        campaign   approx. char(32)
        comments   blob/text
        complete   char(1)
        deleted    char(1)
        order_wday char(10)
        order_ymd  char(8)
        po_number  approx. char(32)
        affiliate  approx. char(32)
        campaign   approx. char(32)
    mv_credit_card_info
    inactive     char(1)
    credit_limit char(14) or decimal(12,2)
    dealer       char(3)
        ## Don't want people setting their credit_limit directly
        UserDB default scratch "credit_limit dealer"

3.5. Affiliates

    affiliate name    campaigns   join_date   url timeout active  password

3.6. Page Editor

3.7. Item Editor

    Database  merchandising  merchandising.txt __SQLDSN__
    Database  merchandising  DEFAULT_TYPE text
    
    sku                 char(32)
    featured            char(32)
    banner_text
    banner_image
    blurb_begin
    blurb_end
    timed_promotion     char(16)
    start_date          char(24)
    finish_date         char(24)
    upsell_to
    cross_sell
    cross_category      char(64)
    others_bought
    times_ordered

3.8. Preferences Editor (KNAR)

    code  Variable  pref_group
    VariableDatabase variable

3.9. Route Editor

            code
            report
            receipt
            encrypt_program
            encrypt
            pgp_key
            pgp_cc_key
            cyber_mode
            credit_card
            profile
            inline_profile
            email
            attach
            counter
            increment
            continue
            partial
            supplant
            track
            errors_to
    RouteDatabase route

3.10. Transactions database


4. Upgrading from Minivend 3 to Minivend 4

4.1. Nested [loop]s

            [loop prefix=size list="Small Medium Large"]
                    [loop prefix=color list="Red White Blue"]
                            [color-code]-[size-code]<BR>
                    [/loop]
                    <P>
            [/loop]

4.2. All frame features removed

4.3. Tags removed

4.3.1. buttonbar

    ButtonBars header.html footer.html copyright.html
    Variable HEADER    <pages/header
    Variable FOOTER    <pages/footer
    Variable COPYRIGHT <pages/copyright

4.3.2. random

4.3.3. rotate

4.3.4. help

4.3.5. body

4.3.6. finish_order

4.3.7. last_page

4.3.8. item-link

4.3.9. loop-link

4.3.10. sql-link

4.3.11. accessories

4.3.12. Compatibility routines

4.4. Directives removed

        ActionMap
        AdminDatabase
        AdminPage
        AsciiBackend
        BackendOrder
        ButtonBars
        CheckoutFrame
        CheckoutPage
        CollectData
        DataDir
        Delimiter
        DescriptionTrim
        FieldDelimiter
        FrameFlyPage
        FrameLinkDir
        FrameOrderPage
        FrameSearchPage
        ItemLinkDir
        ItemLinkValue
        MsqlDB
        MsqlProducts
        Mv_AlinkColor
        Mv_Background
        Mv_BgColor
        Mv_LinkColor
        Mv_TextColor
        Mv_VlinkColor
        NewReport
        NewTags
        OldShipping
        OrderFrame
        PageCache
        PriceDatabase
        Random
        ReceiptPage
        RecordDelimiter
        ReportIgnore
        Rotate
        SearchFrame
        SearchOverMsg
        SecureOrderMsg
        SpecialFile
        SubArgs
        Tracking

4.5. Minor operations removed

4.6. Search lists

    find pages -type f | xargs grep -l '\[search.list'
        [search-region]
    
        [search-list]
            your search iteration stuff, [item-code], etc.
        [/search-list]
    
        [more-list]
            [more]
        [/more-list]
    
        [/search-region]

4.7. Search conditionals

4.8. Form data updates

        [set update_database]
        [set mv_data_enable]1[/set]
        [/set]
        <INPUT TYPE=hidden NAME=mv_click VALUE=update_database>
        [set update_database]
        [if type=data term="userdb::trusted::[data session username]"]
            [set mv_data_enable]1[/set]
        [else]
            [set mv_data_enable]0[/set]
        [/else]
        [/if]
        [/set]

4.9. Checkout changes

4.10. [if-field] etc.

        [if-data table col]  --> [if-PREFIX-data table col]
        [on-change mark]     --> [PREFIX-change mark]
        [if-param param]     --> [if-PREFIX-param param]
        [PREFIX-param N]     --> [PREFIX-pos N] (where N is a digit)

4.11. [search-list]

        $Safe{values}   -->  $Values
        $Safe{cgi}      -->  $CGI
        $Safe{carts}    -->  $Carts
        $Safe{items}    -->  $Items
        $Safe{config}   -->  $Config
        $Safe{scratch}  -->  $Scratch

4.12. Global subs

    [perl sub]
    myfunsub();
    [/perl]
    [perl subs=1]
    myfunsub();
    [/perl]
    115.202.115.237 H8gbq6oK:115.202.115.237 - [28/February/2001:18:58:50 -0500] testcat /cgi-bin/testcat.cgi Safe: Undefined subroutine &MVSAFE::myfunsub called at (eval 283) line 2.

A. Minivend 3 compatibility usertags and globalsubs

A.1. body

    UserTag body PosNumber 2
    UserTag body Order type extra
    UserTag body Routine <<EOR
    use vars qw($C);
    sub parse_color {
        my ($var, $value) = @_;
        return '' unless $value;
        $var = lc $var;
        $C->{Color}->{$var} = [];
        @{$C->{'Color'}->{$var}} = split /\s+/, $value;
        return $value;
    }
    
    sub {
        my($scheme, $extra) = @_;
        my $r = '<BODY';
        my ($var,$tag);
        #return '<BODY>' unless (int($scheme) < 16 and int($scheme) > 1);
    
        my %color = qw( mv_bgcolor BGCOLOR mv_textcolor TEXT
                        mv_linkcolor LINK mv_vlinkcolor VLINK
                        mv_alinkcolor ALINK mv_background BACKGROUND );
        if (defined $::Values->{mv_resetcolors}
                and $::Values->{mv_resetcolors}) {
            delete $::Values->{mv_customcolors};
            undef $::Values->{mv_resetcolors};
        }
        if (defined $::Values->{mv_customcolors}) {
            foreach $var (keys %color) {
                $r .= qq| $color{$var}="| . $::Values->{$var} . '"'
                    if $::Values->{$var};
            }
        }
        else {
            foreach $var (keys %color) {
                $r .= qq| $color{$var}="| . ${$Vend::Cfg->{Color}->{$var}}[$scheme] . '"'
                    if defined ${$Vend::Cfg->{Color}->{$var}}[$scheme]
                        &&  ${$Vend::Cfg->{Color}->{$var}}[$scheme] !~ /\bnone\b/;
            }
        }
        $r =~ s#(BACKGROUND="(?!http:))([^/])#$1$Vend::Cfg->{ImageDir}$2#;
        $r .= " $extra" if defined $extra;
        $r .= '>';
    }
    EOR
    
    AddDirective Mv_Background   color
    AddDirective Mv_BgColor      color
    AddDirective Mv_TextColor    color
    AddDirective Mv_LinkColor    color
    AddDirective Mv_AlinkColor   color
    AddDirective Mv_VlinkColor   color

A.2. buttonbar

    # Returns a buttonbar by number
    UserTag buttonbar Order type
    UserTag buttonbar PosNumber 1
    UserTag buttonbar Interpolate 1
    UserTag buttonbar Routine <<EOR
    sub get_files {
        my($dir, @files) = @_;
        my(@out);
        my($file, $contents);
        foreach $file (@files) {
            config_error(
              "No leading ../.. allowed if NoAbsolute set. Contact administrator.\n")
            if $file =~ m#^\.\./.*\.\.# and $Global::NoAbsolute;
            push(@out,"\n") unless
                push(@out,readfile("$dir/$file.html"));
        }
    
        @out;
    }
    
    sub parse_buttonbar {
        my ($var, $value) = @_;
        return [] unless $value;
        my @c;
        my @vals = grep /\S/, split /\s+/, $value;
        for(@vals) {
            push @c, Vend::Util::readfile("pages/$_.html");
        }
        return \@c;
    }
    
    sub {
        my($buttonbar) = @_;
        if (defined $Vend::Cfg->{'ButtonBars'}->[$buttonbar]) {
            return $Vend::Cfg->{'ButtonBars'}->[$buttonbar];
        }
        else {
            return '';
        }
    }
    EOR
    
    AddDirective ButtonBars  buttonbar

A.3. form_mail.cfg

    GlobalSub <<EndOfSub
    sub form_mail {
        my($to, $subject, $reply, $body) = @_;
        my($ok);
    
        $subject = '<no subject>' unless defined $subject && $subject;
    
        $reply = '' unless defined $reply;
        $reply = "Reply-to: $reply\n" if $reply;
    
        $ok = 0;
        SEND: {
            open(Vend::MAIL,"|$Vend::Cfg->{'SendMailProgram'} -t") or last SEND;
            print Vend::MAIL
                "To: $to\n",
                $reply,
                "Subject: $subject\n",
                "Errors-To: $Vend::Cfg->{MailOrderTo}\n\n",
                $body
                or last SEND;
            close Vend::MAIL or last SEND;
            $ok = ($? == 0);
        }
    
        if (!$ok) {
            logError("Unable to send mail using $Vend::Cfg->{'SendMailProgram'}\n" .
                "To '$to'\n" .
                "With subject '$subject'\n" .
                "With reply-to '$reply'\n" .
                "And body:\n$body");
        }
        $ok;
    }
    EndOfSub

A.4. help

    UserTag help PosNumber 1
    UserTag help Order name
    UserTag help Routine <<EOR
    sub parse_help {
        my ($var, $value) = @_;
        my (@files);
        my (@items);
        my ($c, $chunk, $item, $help, $key);
        unless (defined $value && $value) {
            $c = {};
            return $c;
        }
        $c = $C->{'Help'};
        $var = lc $var;
        $C->{'Source'}->{'Help'} = $value;
        @files = get_files($C->{'PageDir'}, split /\s+/, $value);
        foreach $chunk (@files) {
            @items = split /\r?\n\r?\n/, $chunk;
            foreach $item (@items) {
                ($key,$help) = split /\s*\n/, $item, 2;
                if(defined $c->{$key}) {
                    $c->{$key} .= $help;
                }
                else {
                    $c->{$key} = $help;
                }
    
            }
        }
        return $c;
    }
    
    sub {
        my($help) = shift;
        # Move this to control section?
        if ($::Values->{mv_helpon}) {
            delete $::Values->{mv_helpoff};
            undef $::Values->{mv_helpon};
        }
        return '' if defined $::Values->{'mv_helpoff'};
        if (defined $Vend::Cfg->{'Help'}{$help}) {
            return $Vend::Cfg->{'Help'}{$help};
        }
        else {
            return '';
        }
    }
    EOR
    
    AddDirective Help help

A.5. random_rotate

    UserTag random PosNumber 0
    UserTag random Interpolate 1
    UserTag random Routine <<EOR
    package Vend::Config;
    sub parse_random {
        my ($var, $value) = @_;
        return '' unless (defined $value && $value);
        my $c = [];
        $var = lc $var;
        my @files = grep /\S/, split /\s+/, $value;
        local ($Vend::Cfg) = $C;
        for (@files) { push @$c, Vend::Util::readin($_) }
        return $c;
    }
    
    package Vend::Interpolate;
    sub {
        my $random = int rand(scalar(@{$Vend::Cfg->{'Random'}}));
        if (defined $Vend::Cfg->{'Random'}->[$random]) {
            return $Vend::Cfg->{'Random'}->[$random];
        }
        else {
            return '';
        }
    }
    EOR
    
    UserTag rotate PosNumber 2
    UserTag rotate Order ceiling floor
    UserTag rotate Interpolate 1
    UserTag rotate Routine <<EOR
    sub {
        return '' unless $Vend::Cfg->{Rotate};
        my $ceiling = $_[0] || @{$Vend::Cfg->{'Rotate'}} || return '';
        my $floor   = $_[1] || 1;
    
        $ceiling--;
        $floor--;
    
        my $marker = "rotate$floor$ceiling";
    
        if($ceiling < 0 or $floor < 0) {
            $floor = 0;
            $ceiling = scalar  @{$Vend::Cfg->{'Rotate'}} - 1;
            logError "Bad ceiling or floor for rotate";
        }
    
        my $rotate;
        $rotate = $Vend::Session->{$marker} || $floor;
    
        if($rotate > $ceiling or $rotate < $floor ) {
            $rotate = $floor;
        }
    
        $Vend::Session->{$marker} = $rotate + 1;
        return $Vend::Cfg->{'Rotate'}->[$rotate];
    }
    EOR
    
    AddDirective Random random
    AddDirective Rotate random

A.6. AsciiBackend

    GlobalSub <<EOS
    sub AsciiBackend {
        package Vend::Order;
        $Vend::Order::override_track_order = \&track_order;
        sub track_order_backend {
            my ($order_no,$order_report) = @_;
            my ($c,$i);
            my (@backend);
    
            @backend = split /\s*,\s*/, $Vend::Cfg->{BackendOrder};
    
            if(@backend and $Vend::Cfg->{AsciiBackend}) {
                my(@ary);
                push @ary, $order_no;
                for(@backend) {
                    push @ary, $::Values->{$_};
                }
                foreach $i (0 .. $#$Vend::Items) {
                    push @ary, $Vend::Items->[$i]{'code'};
                    push @ary, $Vend::Items->[$i]{'quantity'};
                    if ($Vend::Cfg->{UseModifier}) {
                        foreach $j (@{$Vend::Cfg->{UseModifier}}) {
                            push @ary, $Vend::Items->[$i]->{$j}
                        }
                    }
                }
                logData ($Vend::Cfg->{AsciiBackend}, @ary);
            }
            $Vend::Order::override_track_order->($order_no, $order_report);
        }
        *track_order = \&Vend::Order::override_track_order;
    }
    EOS
    
    AddDirective BackendOrder
    AddDirective AsciiBackend

5. History of Interchange