From 26402c5c6db611a88f058bff0279b23bccb33957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 10:53:05 +0800 Subject: Template tag for ordering --- config/pikul_order.tag | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 config/pikul_order.tag diff --git a/config/pikul_order.tag b/config/pikul_order.tag new file mode 100644 index 0000000..062d5ac --- /dev/null +++ b/config/pikul_order.tag @@ -0,0 +1,57 @@ +UserTag pikul_order Order order_number insurance +UserTag pikul_order Routine <query({ + sql => "SELECT shipmode,nitems,subtotal,fname,lname,address1,address2,city,state,phone_day \ + FROM transactions WHERE code='$order_number'", + wantarray => 1 + })->[0]}; + my ($table, $service) = split(/_/, shift split(/ /, $shipmode)); + my ($company, @provisions, $origin); + if (substr($table, 0, 8) eq 'anteraja') { + $company = $::Variable->{PIKUL_ANTERAJA}; + @provisions = ( + "$Global::Variable->{ANTERAJA_BASE_PATH}", + "$Global::Variable->{ANTERAJA_ACCESS_KEY_ID}", + "$Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}", + "$Global::Variable->{ANTERAJA_PREFIX}" + ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; + } + my @items = @{$Tag->query({sql => "SELECT sku,quantity FROM orderline WHERE \ + order_number='$order_number'", + wantarray => 1 + })->[0]}; + for my $item (@items) { + ($item->[2], $item->[3], $item->[4]) = @{$Tag->query({ + sql => "SELECT description,price,weight FROM products WHERE sku='$item->[0]'", + wantarray => 1 + })->[0]}; + } + use Pikul; + Pikul::init($company, \@provisions); + my $waybill = Pikul::order( + $order_number, + $service, + $::Variable->{COMPANY}, + $::Variable->{PHONE}, + $origin, + $::Variable->{ADDRESS}, + "$fname $lname", + $phone_day, + $Tag->query({sql => "SELECT code FROM $table WHERE district='$address2' AND city='$city' \ + AND province='$state'", + wantarray => 1 + })->[0]->[0] || '', + $address1, + $nitems, + \@items, + $insurance, + $subtotal + ); + Pikul::cleanup(); + return $waybill; +} +EOR -- cgit v1.2.3