diff options
-rw-r--r-- | config/pikul.tag | 56 | ||||
-rw-r--r-- | pages/ord/checkout.html | 2 |
2 files changed, 32 insertions, 26 deletions
diff --git a/config/pikul.tag b/config/pikul.tag index ea279c2..343e50b 100644 --- a/config/pikul.tag +++ b/config/pikul.tag @@ -1,39 +1,45 @@ -UserTag pikul Order company +UserTag pikul Order widget extra UserTag pikul Routine <<EOR sub { - my ($company) = @_; - my (@provisions, $origin, $table); - if ($company == $::Variable->{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'; - } + 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 $elements; + if ($widget eq 'select') { + $elements = '<select name="mv_shipmode"' . ($extra ? " $extra" : '') . '>'; + } use Pikul; - Pikul::init($company, \@provisions); - my $district = $Tag->value('address2'); - my $city = $Tag->value('city'); - my $province = $Tag->value('state'); - my @codes = @{Pikul::codes( + for (my $company = $::Variable->{PIKUL_ANTERAJA}; $company <= $::Variable->{PIKUL_ANTERAJA}; + $company++) { + my (@provisions, $origin, $table); + if ($company == $::Variable->{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'; + } + 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 = '<select name="mv_shipmode" id="ship_widget" class="form-control" onchange="this.form.submit()">'; - for my $code (@codes) { - $elements .= qq( - <option name="mv_shipmode" value="$table) - . qq(_$code") - . ($Tag->value('mv_shipmode') eq $table . "_$code" ? ' selected' : '') - . ">$table $code</option>"; + Pikul::cleanup(); + for my $code (@codes) { + $elements .= q( + <option value=") + . $table . qq(_$code") + . ($Tag->value('mv_shipmode') eq $table . "_$code" ? ' selected' : '') + . ">$table $code</option>"; + } } $elements .= q( </select>); diff --git a/pages/ord/checkout.html b/pages/ord/checkout.html index 4020ca5..7ea3d5a 100644 --- a/pages/ord/checkout.html +++ b/pages/ord/checkout.html @@ -85,7 +85,7 @@ <div class="block-body"> <div class="row"> <div class="form-group col-md-6 d-flex align-items-center"> - [pikul company="__PIKUL_ANTERAJA__"] + [pikul widget="select" extra='id="ship_widget" class="form-control" onchange="this.form.submit()"'] <label class="ml-3" for="ship_widget"> <strong class="d-block text-uppercase mb-2">[shipping-desc]</strong> <span class="text-muted text-sm"> |