From 8e597aa6979cc414c64224ef1f8c452a4ee78ad5 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: Fri, 16 Jul 2021 15:39:11 +0800 Subject: Origin is set in the template tag --- config/pikul_cost.tag | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'config') diff --git a/config/pikul_cost.tag b/config/pikul_cost.tag index 75e84b9..eb99dde 100644 --- a/config/pikul_cost.tag +++ b/config/pikul_cost.tag @@ -1,21 +1,28 @@ -UserTag pikul_cost Order company origin district city province weight service +UserTag pikul_cost Order company service district city province weight UserTag pikul_cost Routine <{PIKUL_ANTERAJA}) { @provisions = ( "$Global::Variable->{ANTERAJA_BASE_PATH}", "$Global::Variable->{ANTERAJA_ACCESS_KEY_ID}", "$Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}" ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; $table = 'anteraja'; } use Pikul; Pikul::init($company, \@provisions); - my $cost = Pikul::cost($origin, $Tag->query({sql => "SELECT code FROM $table WHERE \ - district='$district' AND city='$city' AND province='$province'", - wantarray => 1})->[0]->[0] || '', $weight, $service); + my $cost = Pikul::cost( + $origin, + $Tag->query({ + sql => "SELECT code FROM $table WHERE district='$district' AND \ + city='$city' AND province='$province'", + wantarray => 1 + })->[0]->[0] || '', + $weight, + $service); Pikul::cleanup(); return $cost; } -- cgit v1.2.3 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 (limited to 'config') 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 From a391dff2fd6ee3300bc0b3f05a4e78d885625365 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 11:01:05 +0800 Subject: So the argument to shift is an array --- config/pikul_order.tag | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 062d5ac..f3de13d 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,5 +1,7 @@ +=pod UserTag pikul_order Order order_number insurance UserTag pikul_order Routine < 1 })->[0]}; - my ($table, $service) = split(/_/, shift split(/ /, $shipmode)); + my ($table, $service) = split(/_/, shift @{split(/ /, $shipmode)}); my ($company, @provisions, $origin); if (substr($table, 0, 8) eq 'anteraja') { $company = $::Variable->{PIKUL_ANTERAJA}; -- cgit v1.2.3 From cb8001b6bf2597d1b7f05d1c12ccc29769932958 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 11:01:34 +0800 Subject: Forgot to remove pod cut --- config/pikul_order.tag | 2 -- 1 file changed, 2 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index f3de13d..6fe34b4 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,7 +1,5 @@ -=pod UserTag pikul_order Order order_number insurance UserTag pikul_order Routine < Date: Sat, 17 Jul 2021 13:18:32 +0800 Subject: Shipmode parts need to be saved into an array before shift --- config/pikul_order.tag | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 6fe34b4..074cc07 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -8,7 +8,8 @@ sub { FROM transactions WHERE code='$order_number'", wantarray => 1 })->[0]}; - my ($table, $service) = split(/_/, shift @{split(/ /, $shipmode)}); + my @parts = split(/ /, $shipmode, 2); + my ($table, $service) = split(/_/, shift @parts); my ($company, @provisions, $origin); if (substr($table, 0, 8) eq 'anteraja') { $company = $::Variable->{PIKUL_ANTERAJA}; -- cgit v1.2.3 From 8afdce3692396d8d18c5f40727fe2fc4da6b4792 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 13:20:49 +0800 Subject: Make sure the variables are set as strings --- config/pikul_order.tag | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 074cc07..de4f7f2 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -19,7 +19,7 @@ sub { "$Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}", "$Global::Variable->{ANTERAJA_PREFIX}" ); - $origin = $::Variable->{ANTERAJA_ORIGIN}; + $origin = "$::Variable->{ANTERAJA_ORIGIN}"; } my @items = @{$Tag->query({sql => "SELECT sku,quantity FROM orderline WHERE \ order_number='$order_number'", @@ -36,10 +36,10 @@ sub { my $waybill = Pikul::order( $order_number, $service, - $::Variable->{COMPANY}, - $::Variable->{PHONE}, + "$::Variable->{COMPANY}", + "$::Variable->{PHONE}", $origin, - $::Variable->{ADDRESS}, + "$::Variable->{ADDRESS}", "$fname $lname", $phone_day, $Tag->query({sql => "SELECT code FROM $table WHERE district='$address2' AND city='$city' \ -- cgit v1.2.3 From bad203691742aecb781702ad1de4fc6e33fec356 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 13:22:04 +0800 Subject: Sometimes there's no array layer from query --- config/pikul_order.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index de4f7f2..0aad5c8 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -24,7 +24,7 @@ sub { 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]'", -- cgit v1.2.3 From d9d526b76e4ff051c2f8fea2cc14809114714b40 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 13:22:34 +0800 Subject: There have to be addresses at this stage --- config/pikul_order.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 0aad5c8..6f22e1d 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -45,7 +45,7 @@ sub { $Tag->query({sql => "SELECT code FROM $table WHERE district='$address2' AND city='$city' \ AND province='$state'", wantarray => 1 - })->[0]->[0] || '', + })->[0]->[0], $address1, $nitems, \@items, -- cgit v1.2.3 From 7075a6c4130e8eaf48a05b0d8567887b3693c3b3 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 15:40:25 +0800 Subject: Postal codes for both sender & receiver --- config/pikul_order.tag | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 6f22e1d..181923e 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -2,10 +2,11 @@ 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'", + sql => "SELECT shipmode,nitems,subtotal,fname,lname,address1,address2,city,state,zip,\ + phone_day FROM transactions WHERE code='$order_number'", wantarray => 1 })->[0]}; my @parts = split(/ /, $shipmode, 2); @@ -40,6 +41,7 @@ sub { "$::Variable->{PHONE}", $origin, "$::Variable->{ADDRESS}", + "$::Variable->{POSTAL_CODE}", "$fname $lname", $phone_day, $Tag->query({sql => "SELECT code FROM $table WHERE district='$address2' AND city='$city' \ @@ -47,6 +49,7 @@ sub { wantarray => 1 })->[0]->[0], $address1, + $zip, $nitems, \@items, $insurance, -- cgit v1.2.3 From 3f7029884a03c9b58f850b08ba80113e43d4e329 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 19:51:30 +0800 Subject: Programatically set tracking_number The transaction data is only being made at this stage, that's why it didn't work by searching it from the database. --- config/pikul_order.tag | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 181923e..5711c39 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,14 +1,8 @@ -UserTag pikul_order Order order_number insurance +UserTag pikul_order Order order_number shipmode nitems subtotal fname lname address1 address2 city state zip phone_day insurance UserTag pikul_order Routine <query({ - sql => "SELECT shipmode,nitems,subtotal,fname,lname,address1,address2,city,state,zip,\ - phone_day FROM transactions WHERE code='$order_number'", - wantarray => 1 - })->[0]}; + my ($order_number, $shipmode, $nitems, $subtotal, $fname, $lname, $address1, $address2, $city, + $state, $zip, $phone_day, $insurance) = @_; my @parts = split(/ /, $shipmode, 2); my ($table, $service) = split(/_/, shift @parts); my ($company, @provisions, $origin); -- cgit v1.2.3 From 4252d35ad7bf4013464fc9a4d0ccf054ad7da626 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 20:41:25 +0800 Subject: Revert "Programatically set tracking_number" This reverts commit 3f7029884a03c9b58f850b08ba80113e43d4e329. --- config/pikul_order.tag | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 5711c39..181923e 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,8 +1,14 @@ -UserTag pikul_order Order order_number shipmode nitems subtotal fname lname address1 address2 city state zip phone_day insurance +UserTag pikul_order Order order_number insurance UserTag pikul_order Routine <query({ + sql => "SELECT shipmode,nitems,subtotal,fname,lname,address1,address2,city,state,zip,\ + phone_day FROM transactions WHERE code='$order_number'", + wantarray => 1 + })->[0]}; my @parts = split(/ /, $shipmode, 2); my ($table, $service) = split(/_/, shift @parts); my ($company, @provisions, $origin); -- cgit v1.2.3 From aa6b47e1fc6298b9cc01d4e5a5247b805c40c9fe 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 20:44:56 +0800 Subject: Programmatically set tracking_number Easier to do everything after the transaction is made. --- config/pikul_order.tag | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 181923e..29541a9 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -34,7 +34,7 @@ sub { } use Pikul; Pikul::init($company, \@provisions); - my $waybill = Pikul::order( + my $tracking_number = Pikul::order( $order_number, $service, "$::Variable->{COMPANY}", @@ -56,6 +56,8 @@ sub { $subtotal ); Pikul::cleanup(); - return $waybill; + $Tag->query({sql => "UPDATE transactions SET tracking_number='$tracking_number' WHERE \ + code='$order_number'"}); + return $tracking_number; } EOR -- cgit v1.2.3 From 09e0d9b7a770484fdf425c1fc6c05c095f2722b0 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 20:51:49 +0800 Subject: The order matters Somehow I got a blank page when querying after cleanup? No time to find out the answer why. This works. --- config/pikul_order.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 29541a9..4996658 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -55,9 +55,9 @@ sub { $insurance, $subtotal ); - Pikul::cleanup(); $Tag->query({sql => "UPDATE transactions SET tracking_number='$tracking_number' WHERE \ code='$order_number'"}); + Pikul::cleanup(); return $tracking_number; } EOR -- cgit v1.2.3 From 3fe050402dc2afbee8ecc5d3f67576790f7c5d62 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: Sun, 18 Jul 2021 12:07:14 +0800 Subject: Insurance isn't user's decision --- config/pikul_order.tag | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 4996658..0936442 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,7 +1,6 @@ -UserTag pikul_order Order order_number insurance UserTag pikul_order Routine <query({ @@ -52,7 +51,6 @@ sub { $zip, $nitems, \@items, - $insurance, $subtotal ); $Tag->query({sql => "UPDATE transactions SET tracking_number='$tracking_number' WHERE \ -- cgit v1.2.3 From c10cde30d86bddd720480bd535582151a816d1cc 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: Sun, 18 Jul 2021 12:26:32 +0800 Subject: The correct syntax The quotes and parameter name must be retained. I guess it takes some more effort to make some parameter default, or to enable arguments without quotes. --- config/pikul_order.tag | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/pikul_order.tag b/config/pikul_order.tag index 0936442..08bbffb 100644 --- a/config/pikul_order.tag +++ b/config/pikul_order.tag @@ -1,3 +1,4 @@ +UserTag pikul_order Order order_number UserTag pikul_order Routine <