[ic] Re: Accessing looped data in a usertag
Ron Phipps
ron at endpoint.com
Tue Mar 18 21:22:30 EST 2008
Grant wrote:
>> My perl skills are weak. Could anyone tell me the best way to access
>> all orderline table data for an order inside a usertag?
>>
>> - Grant
>
> I've been working on this for many hours and am still stuck. I
> basically need something like this to work:
>
> $Tag->loop({ search =>
> "fi=orderline/ml=999999/st=db/sf=order_number/se=1234/op=eq/nu=0" },
> $text->text("$Tag->loop-code");
>
> I've fiddled with the syntax ad nauseum and tried every different
> approach I can think of but I can't get it to behave like it does
> outside of a usertag. Could someone point me in the right direction?
>
> - Grant
Hi Grant,
You may want to try using a query to pull the orderline data, something like this in a usertag:
my $db = Vend::Data::database_exists_ref('orderline');
my $sql = "SELECT code, sku FROM orderline WHERE order_number = '1234'";
my $dbh = $db->[$Vend::Table::DBI::DBI];
my $sth = $dbh->prepare($sql);
$sth->execute();
if ($sth) {
while (my $sql_results = $sth->fetchrow_hashref()) {
my $code = $$sql_results{code};
my $sku = $$sql_results{sku};
}
}
Take it easy,
--
Ron Phipps
End Point Corporation
ron at endpoint.com
More information about the interchange-users
mailing list