[ic] [item-subtotal] manually

Doug Alcorn interchange-users@lists.akopia.com
Wed May 30 15:56:00 2001


Ed LaFrance <edl@newmediaems.com> writes:

> At 01:43 PM 05/30/2001 -0400, you wrote:
> >Ed LaFrance <edl@newmediaems.com> writes:
> >
> > > At 12:37 PM 05/30/2001 +0400, you wrote:
> > > >Hi, people!
> > > >
> > > >I need correct [item-subtotal] calculate mechanism.
> > >
> > > I would guess that the best course of action for you would be to
> > > override the item_subtotal subroutine in Data.pm.
> >
> >Here is the relevant info from the link Ed gives:
> >
> >,----[ http://developer.akopia.com/cgi-bin/ic/dev/icconfig_27.html ]
>
> The gist of the thrust is this: the above example allows you to
> effectively replace the fictitous subroutine 'to_overrride' in
> Module.pm with your own customized version.  So, in the case of Sergey
> Sheykin's question regarding rolling his own item-subtotal, he could
> write a custom version of the 'item_subtotal' routine (located in
> Data.pm) and include it as shown above in his interchange.cfg (or
> catalog.cfg if AllowGlobal is enabled for that catalog).  Then, each
> time the [item-subtotal] tag is evaluated, his routine would be used
> INSTEAD of the standard one in Data.pm.  It is much like hacking the
> code, except that it affords some degree of portability.
> 

OK, this answers the practical question I think.  Let's take a
concrete example:

 GlobalSub <<EOS
 sub just_for_overriding {
    package Vend::Data;
    use MyModule;
    sub item_subtotal {
       &MyModule::do_something_funky($Values->{my_variable});
    }
 }
 EOS

According to your comment, every time [item-subtotal] gets evaluated
MyModule::do_something_funky() gets called instead of
Vend::Data::item_subtotal().  The theoretical question is this, how
does this work?  If you put the above snippet in the catalog.cfg who
calls just_for_overriding?  Does it automatically get executed when
the IC daemon starts?
-- 
 (__) Doug Alcorn (mailto:doug@lathi.net http://www.lathi.net)
 oo / PGP 02B3 1E26 BCF2 9AAF 93F1  61D7 450C B264 3E63 D543
 |_/  If you're a capitalist and you have the best goods and they're
      free, you don't have to proselytize, you just have to wait.