From 9e1956b7de95179d6b488d6a01fcb8046a821ef2 Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Tue, 20 Jul 2021 00:15:43 +0800 Subject: Tag to show service codes already wrapped in select option HTML elements. --- config/pikul_codes.tag | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 config/pikul_codes.tag (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag new file mode 100644 index 0000000..f8c99cb --- /dev/null +++ b/config/pikul_codes.tag @@ -0,0 +1,36 @@ +UserTag pikul-codes Order company district city province weight +UserTag pikul-codes Routine <{PIKUL_ANTERAJA}) { + @provisions = ( + $Global::Variable->{ANTERAJA_ACCESS_KEY_ID}, + $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY}, + $Global::Variable->{ANTERAJA_BASE_PATH} + ); + $origin = $::Variable->{ANTERAJA_ORIGIN}; + $table = 'anteraja'; + } + use Pikul; + Pikul::init($company, \@provisions); + my @codes = @{Pikul::codes( + $origin, + $Tag->query({ + sql => "SELECT code FROM $table WHERE district='$district' AND \ + city='$city' AND province='$province'", + wantarray => 1 + })->[0]->[0] || '', + $weight)}; + Pikul::cleanup(); + my $elements = ''; + return $elements; +} +EOR -- cgit v1.3 From 76bda3da1176fee9603e69274086085fbb85953e Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Tue, 20 Jul 2021 00:20:29 +0800 Subject: Reindented --- config/pikul_codes.tag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index f8c99cb..377aad2 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -27,10 +27,10 @@ sub { my $mv_shipmode = $Tag->value('mv_shipmode'); for my $i (0 .. $#codes) { $elements .= qq! - !; + !; } $elements .= q' - '; + '; return $elements; } EOR -- cgit v1.3 From b521361bfc18d0fcbe7773018f8f34e1b6900eae Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Tue, 20 Jul 2021 00:30:25 +0800 Subject: Tidy up --- config/pikul_codes.tag | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index 377aad2..4169c0b 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -26,11 +26,16 @@ sub { my $elements = ''; + $elements .= q( + ); return $elements; } EOR -- cgit v1.3 From 0550cb43f08b97292639f800512df3965ee96df1 Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Tue, 20 Jul 2021 14:34:23 +0800 Subject: mv_shipmode seems to be always submitted --- config/pikul_codes.tag | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index 4169c0b..fb4a0e6 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -24,15 +24,12 @@ sub { $weight)}; Pikul::cleanup(); my $elements = '); -- cgit v1.3 From 488e6e8145ce64dd124ba6187a5d7b5813bb927b Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Tue, 20 Jul 2021 14:50:48 +0800 Subject: Trying to get weight shouldn't be the template user's concern --- config/pikul_codes.tag | 8 ++++++-- pages/ord/checkout.html | 10 ++-------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'config') diff --git a/config/pikul_codes.tag b/config/pikul_codes.tag index fb4a0e6..71fd5cc 100644 --- a/config/pikul_codes.tag +++ b/config/pikul_codes.tag @@ -1,7 +1,7 @@ -UserTag pikul-codes Order company district city province weight +UserTag pikul-codes Order company district city province UserTag pikul-codes Routine <{PIKUL_ANTERAJA}) { @provisions = ( @@ -12,6 +12,10 @@ sub { $origin = $::Variable->{ANTERAJA_ORIGIN}; $table = 'anteraja'; } + my $weight = 0.0; + for my $item (@{$Carts->{main}}) { + $weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity}; + } use Pikul; Pikul::init($company, \@provisions); my @codes = @{Pikul::codes( diff --git a/pages/ord/checkout.html b/pages/ord/checkout.html index ae2e694..19617fe 100644 --- a/pages/ord/checkout.html +++ b/pages/ord/checkout.html @@ -84,14 +84,8 @@
-
[tmp weight][perl products] - my $weight = 0.0; - for my $item (@{$Carts->{main}}) { - $weight += tag_data('products', 'weight', "$item->{code}") * $item->{quantity}; - } - return $weight; - [/perl][/tmp] - [pikul_codes company="__PIKUL_ANTERAJA__" district="[value address2]" city="[value city]" province="[value state]" weight="[scratch weight]"] +
+ [pikul_codes company="__PIKUL_ANTERAJA__" district="[value address2]" city="[value city]" province="[value state]"]