1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
UserTag pikul Order widget extra
UserTag pikul Routine <<EOR
sub {
my ($widget, $extra) = @_;
my $district = $Tag->value('address2');
my $city = $Tag->value('city');
my $province = $Tag->value('state');
my $weight = 0.0;
for my $item (@{$Carts->{main}}) {
$weight += $Tag->data('products', 'weight', $item->{code}) * $item->{quantity};
}
my (@origins, @destinations, @code_prefixes, @name_prefixes);
use Pikul;
for (my $company = $::Variable->{PIKUL}; $company < $::Variable->{PIKUL_END}; $company++) {
if ($company == $::Variable->{PIKUL}) {
$origins[$company] = undef;
$destinations[$company] = undef;
$code_prefixes[$company] = undef;
$name_prefixes[$company] = undef;
} elsif ($company == $::Variable->{PIKUL_ANTERAJA}) {
my $access_key_id = $::Variable->{ANTERAJA_ACCESS_KEY_ID}
|| $Global::Variable->{ANTERAJA_ACCESS_KEY_ID};
my $secret_access_key = $::Variable->{ANTERAJA_SECRET_ACCESS_KEY}
|| $Global::Variable->{ANTERAJA_SECRET_ACCESS_KEY};
my $base_path = $::Variable->{ANTERAJA_BASE_PATH}
|| $Global::Variable->{ANTERAJA_BASE_PATH};
if (!$access_key_id || !$secret_access_key || !$base_path) {
$origins[$company] = undef;
$destinations[$company] = undef;
$code_prefixes[$company] = undef;
$name_prefixes[$company] = undef;
next;
}
Pikul::init($company, [
$access_key_id,
$secret_access_key,
$base_path
]);
$origins[$company] = $::Variable->{ANTERAJA_ORIGIN}
|| $Global::Variable->{ANTERAJA_ORIGIN};
$destinations[$company] = $Tag->query({sql => "SELECT code FROM anteraja WHERE \
district='$district' AND city='$city' AND province='$province'",
wantarray => 1})->[0]->[0] || '';
$code_prefixes[$company] = 'anteraja_';
$name_prefixes[$company] = 'Anteraja ';
}
}
my $elements = Pikul::html(
\@origins,
\@destinations,
$weight,
$widget,
$extra,
'mv_shipmode',
$Tag->value('mv_shipmode'),
\@code_prefixes,
\@name_prefixes
);
Pikul::cleanup();
return $elements;
}
EOR
|