[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
NOT SOLVED! [ic] User tag on CommonAdjust producing an errormessage
Barry Treahy, Jr. wrote:
> Kevin Walsh wrote:
>
>>> w2k.mmaz.com MxyBptP2:192.168.10.10 - [30/August/2002:15:17:14
>>> -0400] mmb2c /cgi-bin/mmb2c/TRM-2194-05-EMI-02.html Safe: Can't
>>> locate object method "open_table" via package "Vend::Table::GDBM"
>>> (perhaps you forgot to load "Vend::Table::GDBM"
>>> ?) at /ibin/interchange/lib/Vend/Data.pm line 910.
>>> >
>>> > $Tag->tier_pricing( $item->{code}, $item->{quantity} )
>>> >
>>>
>>> After testing with the change, I started working on other parts of
>>> the system and when reviewing the log for another reason, I saw
>>> this! It return, though it appears to be complaining about a
>>> different routine. In a nutshell, this is what is in the usertag:
>>>
>>> my $sql = "select quantity,discount from tiers where tier='" .
>>> $tier ."' order by code desc";
>>> my $db = ::database_exists_ref('tiers') or die 'Missing tiers table';
>>> my $results = $db->query({sql => $sql});
>>>
>>> What kills me is that the code works, so why is IC complaining about
>>> it?
>>>
>>>
>>
>> Have you created a test tag with just those three lines and some
>> sort of test return value, such as 123? I'd be surprised if you
>> got the same error message, or anything similar.
>>
>> If you post the entire UserTag, perhaps something could be suggested.
>> It's usually better to post a code snippet, as you have done, but I
>> can't see anything functionally wrong with what you posted. Of course,
>> I could be missing something.
>>
>>
> Hi Kevin,
>
> boy it has been a long weekend and still no launch, though I'm very
> close. Still struggling with VAT issues for UK only orders and a few
> other irritations but regarding your request for the entire tag, here
> it is with commented out experiments and all:
>
> bash# cat /ibin/interchange/usertag/tier*
> # [tier_pricing sku= quantity= ]
> #
> # This tag allows the support for multi-tiered quantity based
> # pricing based on details from Kevin's IC post. At this time,
> # the only place this tag is used is on the CommonAdjust
> # statement for the catalog
> #
> #PriceField 0
> #CommonAdjust "& $Tag->tier_pricing( $item->{code}, $item->{quantity} )"
> #
> UserTag tier_pricing Order sku quantity
> UserTag tier_pricing Routine <<EOR
> sub
> {
> my ($sku, $quantity) = @_;
> my $return;
> # $Tag->iclog("tier_pricing: Startup: sku: " . $sku . ", quantity: "
> . $quantity);
> my $factor = 100.00; #0% off today!
> my $price = $Tag->data( {
> table => 'products',
> field => 'price',
> key => $sku,
> });
> my $tier = $Tag->data( {
> table => 'products',
> field => 'tier',
> key => $sku,
> });
>
> my $sql = "select quantity,discount from tiers where tier='" . $tier
> "' order by code desc";
>
> #here you must use the wantarray => 1, cause the documentation says so :)
> #The documentation also says that using that will return an arrayref
> of your
> #results, a hashref of the column names, and an arrayref of the column
> names.
> #
> # Original
> # my ($results,$colname_hashref,$colname_arrayref) = $Tag->query({
> wantarray =>1,sql => $sql, } );
> # still use simplied version as easier on eyes, still works, and
> didn't stop the errors...
> my $results = $Tag->query({ wantarray => 1,sql => $sql } );
> # This variation worked but produced the same error, different module
> # my $db = ::database_exists_ref('tiers') or die 'Missing tiers table';
> # my $results = $db->query({sql => $sql});
>
> #take the arrayref, and convert to an array @results, which is an
> array of array refs.
> #Arg, what a headarch, these level of deferrals have really lost me so
> just make it work!
> my @results = @{$results};
> my $notfound = 1;
> my $loadit = 0;
> my $toggle = 0;
> foreach my $ref (@results) {
> my @tmp = @{$ref}; #dereference each arrayref
> foreach my $test (@tmp) { #@temp now holds actual (dereferenced)
> results
> if ($notfound == 1) {
> if ($toggle == 0) {
> # $Tag->iclog("tier_pricing: Quantity: " . $test);
> $toggle = 1;
> # Per BVC, we are not allowing the 200 qty or above!?!? Go figure!
> if ($quantity >= 200) {
> if ($test < 200) {$loadit = 1; }
> } else {
> if ($test <= $quantity) {$loadit = 1;}
> }
> } else {
> # $Tag->iclog("tier_pricing: Discount: " . $test);
> $toggle = 0;
> if ($loadit == 1) {
> $return = $test;
> $loadit = 0;
> $notfound = 0;
> }
> }
> }
> }
> }
>
> #just for debug:
> # $Tag->iclog("tier_pricing: return: " . $return);
> $factor=$return;
> # if ($price ne $price + 0.0) {
> # $Tag->iclog("tier_pricing: locale error: $price " , $price+0.0);
> # return 0;
> # }
> # $Tag->iclog("tier_pricing: Ending: sql: " . $sql . ", sku: " . $sku
> . ", tier: " . $tier . ", quantity: " . $quantity . ", factor: " .
> $factor . ", pricing: " . $price);
> $price = $price * $factor;
> return $price;
> }
> EOR
> bash#
>
> Please note that I'm still learning Perl and I'm sure that someone
> like a Schwartz could have pobably done the above in a three line
> statement, but I'm still attempting to develope my skills there, in IC
> and not bug the list for each and everything little thing if I can
> find a 'brute-force' method of at least getting it to work...
>
> As for reducing the take down to just three lines, I did that and the
> query still produced the results. What fogs my mind is that even with
> the errors, the CommonAdjust has never failed to work...
>
We are in final test today to go live. With the prior posting of the
entire usertag, has anyone seen what is causing this:
w2k.mmaz.com fHzmTUod:192.168.10.10 - [04/September/2002:09:48:03 -0400]
mmb2c /cgi-bin/mmb2c/CSY-SMSM-58-024-IS.html Safe: Can't locate object
method "query" via package "Vend::Table::GDBM" (perhaps you forgot to
load "Vend::Table::GDBM"?)
at /ibin/interchange/lib/Vend/Interpolate.pm line 5235.
>
> $Tag->tier_pricing( $item->{code}, $item->{quantity} )
>
continual error message? Is this an IC bug or something that can be
quickly and easily fixed?
Barry
--
Barry Treahy, Jr * Midwest Microwave * Vice President & CIO
E-mail: Treahy@mmaz.com * Phone: 480/314-1320 * FAX: 480/661-7028