implemented shipping cost calculation based on weight


			
			
				2.0@2770
			
			
		
Daniel Tiefnig 17 years ago
parent 6526ddcac6
commit 8bf1737e59

@ -52,11 +52,11 @@ sub hardware : Local {
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
my (@cart, $price_sum);
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
push @cart, { count => $c->session->{shop}{cart}{$ci}{count},
push @cart, { count => $c->session->{shop}{cart}{$ci},
product => $ci,
price => $c->session->{shop}{cart}{$ci}{price_sum}
price => sprintf("%.2f", $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100)
};
$price_sum += $c->session->{shop}{cart}{$ci}{price_sum};
$price_sum += $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100;
}
$c->stash->{price_sum} = sprintf "%.2f", $price_sum;
$c->stash->{cart} = \@cart;
@ -103,12 +103,7 @@ sub add_to_cart : Local {
}
$c->log->info("***shop::add_to_cart adding $count '$product' to cart");
$c->session->{shop}{cart}{$product}{count} += $count;
$c->session->{shop}{cart}{$product}{handle} = $product;
$c->session->{shop}{cart}{$product}{name} = $c->session->{shop}{dbprodhash}{$product}{name};
$c->session->{shop}{cart}{$product}{price} = sprintf "%.2f", $c->session->{shop}{dbprodhash}{$product}{price} / 100;
$c->session->{shop}{cart}{$product}{price_sum} =
sprintf "%.2f", $c->session->{shop}{cart}{$product}{count} * $c->session->{shop}{cart}{$product}{price};
$c->session->{shop}{cart}{$product} += $count;
$c->response->redirect('/shop/hardware?sk='. $c->session->{shop}{session_key});
return;
@ -153,17 +148,17 @@ sub show_cart : Local {
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
my (@cart, $price_sum);
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
push @cart, { count => $c->session->{shop}{cart}{$ci}{count},
product => $c->session->{shop}{cart}{$ci}{name},
push @cart, { count => $c->session->{shop}{cart}{$ci},
handle => $ci,
price => $c->session->{shop}{cart}{$ci}{price},
price_sum => $c->session->{shop}{cart}{$ci}{price_sum},
product => $c->session->{shop}{dbprodhash}{$ci}{name},
price => sprintf("%.2f", $c->session->{shop}{dbprodhash}{$ci}{price} / 100),
price_sum => sprintf("%.2f", $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100),
};
$price_sum += $c->session->{shop}{cart}{$ci}{price_sum};
$price_sum += $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100;
}
$c->stash->{price_sum} = sprintf "%.2f", $price_sum;
$c->stash->{tax_sum} = sprintf "%.2f", $price_sum * 0.2;
$c->stash->{price_with_tax} = sprintf "%.2f", $c->stash->{price_sum} + $c->stash->{tax_sum};
# $c->stash->{tax_sum} = sprintf "%.2f", $price_sum * 0.2;
# $c->stash->{price_with_tax} = sprintf "%.2f", $c->stash->{price_sum} + $c->stash->{tax_sum};
$c->stash->{cart} = \@cart;
} else {
$c->stash->{price_sum} = '0.00';
@ -201,9 +196,7 @@ sub update_cart : Local {
if($count) {
$c->log->info("***shop::update_cart setting '$product' count to '$count'");
$c->session->{shop}{cart}{$product}{count} = $count;
$c->session->{shop}{cart}{$product}{price_sum} =
sprintf "%.2f", $c->session->{shop}{cart}{$product}{count} * $c->session->{shop}{cart}{$product}{price};
$c->session->{shop}{cart}{$product} = $count;
} else {
$c->log->info("***shop::update_cart removing '$product' from cart");
delete $c->session->{shop}{cart}{$product};
@ -816,24 +809,37 @@ sub overview : Local {
$c->stash->{sk} = $c->session->{shop}{session_key};
$c->stash->{tarif} = $c->session->{shop}{tarif};
$c->session->{shop}{shipping_weight} = 0;
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
my @cart;
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
push @cart, { count => $c->session->{shop}{cart}{$ci}{count},
product => $c->session->{shop}{cart}{$ci}{name},
price => $c->session->{shop}{cart}{$ci}{price},
price_sum => $c->session->{shop}{cart}{$ci}{price_sum},
push @cart, { count => $c->session->{shop}{cart}{$ci},
product => $c->session->{shop}{dbprodhash}{$ci}{name},
handle => $ci,
price => sprintf("%.2f", $c->session->{shop}{dbprodhash}{$ci}{price} / 100),
price_sum => sprintf("%.2f", $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100),
};
$c->session->{shop}{shipping_weight} += $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{weight};
}
$c->stash->{cart} = \@cart;
} elsif(ref $c->session->{shop}{system} eq 'HASH') {
$c->stash->{system} = $c->session->{shop}{system};
$c->stash->{phones} = $c->session->{shop}{phones};
$c->session->{shop}{shipping_weight} = $c->session->{shop}{dbprodhash}{$c->session->{shop}{system}{handle}}{weight};
if(ref $c->session->{shop}{phones} eq 'ARRAY' and @{ $c->session->{shop}{phones} }) {
for(@{ $c->session->{shop}{phones} }) {
$c->session->{shop}{shipping_weight} += $$_{count} * $c->session->{shop}{dbprodhash}{$$_{handle}}{weight};
}
}
}
$c->session->{shop}{price_sum} = $self->_calculate_price_sum($c);
$c->stash->{price_sum} = $c->session->{shop}{price_sum};
$c->stash->{month_sum} = sprintf "%.2f", $c->stash->{tarif}{monthly} || 0;
$c->stash->{shipping_weight} = sprintf "%.1f", $c->session->{shop}{shipping_weight} / 1000;
# TODO: calculate costs from weight
$c->stash->{shipping_fee} = $c->session->{shop}{shipping_fee} = '9.50';
$c->stash->{price_sum2} = sprintf "%.2f", $c->session->{shop}{price_sum} + $c->stash->{shipping_fee};
$c->stash->{price_tax} = sprintf "%.2f", $c->stash->{price_sum2} * .2;
@ -918,7 +924,7 @@ sub _calculate_price_sum : Private {
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
$price += $c->session->{shop}{cart}{$ci}{price_sum};
$price += $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100;
}
} else {
$price = $c->session->{shop}{system}{price} || 0;
@ -1047,20 +1053,20 @@ sub _create_contracts : Private {
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
$ci = $c->session->{shop}{cart}{$ci};
next if ref $$ci{contract_ids} eq 'ARRAY' and scalar @{ $$ci{contract_ids} } == $$ci{count};
my $start = ref $$ci{contract_ids} eq 'ARRAY' ? scalar @{ $$ci{contract_ids} } : 1;
for($start .. $$ci{count}) {
next if ref $c->session->{shop}{contracts}{$ci} eq 'ARRAY'
and scalar @{ $c->session->{shop}{contracts}{$ci} } == $c->session->{shop}{cart}{$ci};
my $start = ref $c->session->{shop}{contracts}{$ci} eq 'ARRAY' ? scalar @{ $c->session->{shop}{contracts}{$ci} } : 1;
for($start .. $c->session->{shop}{cart}{$ci}) {
my $contract_id;
$c->model('Provisioning')->call_prov($c, 'billing', 'create_hardware_contract',
{ product => $$ci{handle},
{ product => $ci,
customer_id => $c->session->{shop}{customer_id},
status => 'pending',
order_id => $c->session->{shop}{order_id},
},
\$contract_id
) or return;
push @{ $$ci{contract_ids} }, $contract_id;
push @{ $c->session->{shop}{contracts}{$ci} }, $contract_id;
}
}
} else {
@ -1142,41 +1148,40 @@ aufgenommen:
");
$smtp->datasend("AUFTRAGSNUMMER: ". $c->session->{shop}{dbinvoice} ."\n");
$smtp->datasend("
Einmalig Monatlich
Einmalig Monatlich
--------------------------------------------------------------------
");
$smtp->datasend("1x Tarif ". $c->session->{shop}{tarif}{name} .
" " x (31 - length $c->session->{shop}{tarif}{name}) .
" " x (34 - length $c->session->{shop}{tarif}{name}) .
"EUR ". $c->session->{shop}{tarif}{price} .
" " x (15 - length $c->session->{shop}{tarif}{price}) .
" " x (12 - length $c->session->{shop}{tarif}{price}) .
"EUR ". $c->session->{shop}{tarif}{monthly} ."\n")
if $c->session->{shop}{tarif}{name};
$smtp->datasend("1x Startguthaben ". " " x 23 .
$smtp->datasend("1x Startguthaben ". " " x 26 .
"EUR ". $c->session->{shop}{tarif}{initial_charge} .
" " x (15 - length $c->session->{shop}{tarif}{initial_charge}) .
" " x (12 - length $c->session->{shop}{tarif}{initial_charge}) .
"EUR 0.00\n")
if $c->session->{shop}{tarif}{initial_charge};
if(ref $c->session->{shop}{cart} eq 'HASH' and keys %{$c->session->{shop}{cart}}) {
foreach my $ci (sort keys %{$c->session->{shop}{cart}}) {
my $tprice = sprintf("%.2f", $c->session->{shop}{cart}{$ci}{count} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100);
$smtp->datasend($c->session->{shop}{cart}{$ci}{count} ."x ". $ci .
" " x ((38 - length $c->session->{shop}{cart}{$ci}{count}) - length $ci) .
"EUR ". $c->session->{shop}{cart}{$ci}{price_sum} .
" " x (15 - length $c->session->{shop}{cart}{$ci}{price_sum}) . "EUR 0.00\n");
my $tprice = sprintf("%.2f", $c->session->{shop}{cart}{$ci} * $c->session->{shop}{dbprodhash}{$ci}{price} / 100);
$smtp->datasend($c->session->{shop}{cart}{$ci} ."x ". $c->session->{shop}{dbprodhash}{$ci}{name} .
" " x ((41 - length $c->session->{shop}{cart}{$ci}) - length $c->session->{shop}{dbprodhash}{$ci}{name}) .
"EUR ". $tprice . " " x (12 - length $tprice) . "EUR 0.00\n");
}
} else {
$smtp->datasend("1 x ". $c->session->{shop}{system}{name} .
" " x (36 - length $c->session->{shop}{system}{name}) .
$smtp->datasend("1x ". $c->session->{shop}{system}{name} .
" " x (40 - length $c->session->{shop}{system}{name}) .
"EUR ". $c->session->{shop}{system}{price} .
" " x (15 - length $c->session->{shop}{system}{price}) .
" " x (12 - length $c->session->{shop}{system}{price}) .
"EUR 0.00\n")
if $c->session->{shop}{system}{name};
if(ref $c->session->{shop}{phones} eq 'ARRAY') {
foreach my $phone (@{$c->session->{shop}{phones}}) {
$smtp->datasend($$phone{count} ." x ". $$phone{name} .
" " x (32 - length $$phone{count} - length $$phone{name}) .
$smtp->datasend($$phone{count} ."x ". $$phone{name} .
" " x ((41 - length $$phone{count}) - length $$phone{name}) .
"EUR ". $$phone{price_sum} .
" " x (15 - length $$phone{price_sum}) .
" " x (12 - length $$phone{price_sum}) .
"EUR 0.00\n");
}
}
@ -1184,33 +1189,34 @@ aufgenommen:
$smtp->datasend("--------------------------------------------------------------------\n");
my $price_sum1 = $self->_calculate_price_sum($c);
$smtp->datasend("Zwischensumme" . " " x 27 .
$smtp->datasend("Zwischensumme" . " " x 30 .
"EUR ". $price_sum1 .
" " x (15 - length $price_sum1) .
" " x (12 - length $price_sum1) .
"EUR ". ($c->session->{shop}{tarif}{monthly} || '0.00') ."\n");
$smtp->datasend("+Versandkosten". " " x 26 .
$smtp->datasend("+Versandkosten". " " x 29 .
"EUR ". $c->session->{shop}{shipping_fee} .
" " x (15 - length $c->session->{shop}{shipping_fee}) .
" " x (12 - length $c->session->{shop}{shipping_fee}) .
"EUR 0.00\n");
my $price_tax = sprintf "%.2f", ($price_sum1 + $c->session->{shop}{shipping_fee}) * .2;
my $month_tax = sprintf "%.2f", ($c->session->{shop}{tarif}{monthly} || 0) * .2;
$smtp->datasend("+20% USt". " " x 32 .
$smtp->datasend("+20% USt". " " x 35 .
"EUR ". $price_tax .
" " x (15 - length $price_tax) .
" " x (12 - length $price_tax) .
"EUR ". $month_tax ."\n");
$smtp->datasend("--------------------------------------------------------------------\n");
$smtp->datasend("\n");
my $month_sum = sprintf "%.2f", ($c->session->{shop}{tarif}{monthly} || 0) + $month_tax;
$smtp->datasend("Summe" . " " x 35 .
$smtp->datasend("Summe" . " " x 38 .
"EUR ". $c->session->{shop}{price_sum} .
" " x (15 - length $c->session->{shop}{price_sum}) .
" " x (12 - length $c->session->{shop}{price_sum}) .
"EUR ". $month_sum ."\n");
$smtp->datasend("\n\n");
$smtp->datasend("GESAMTBETRAG:". " " x 5 . "EUR ". $c->session->{shop}{price_sum} ." inkl. USt\n");
$smtp->datasend("\n");
$smtp->datasend("VERSANDART:". " " x 7 . "Hermes Paketversand\n");
$smtp->datasend("VERSANDART:". " " x 7 . "Hermes Paketversand, ".
sprintf("%.1f", $c->session->{shop}{shipping_weight} / 1000) ." kg\n");
$smtp->datasend("\n");
$smtp->datasend("RECHNUNGSADRESSE: " . $c->session->{shop}{personal}{firstname} ." ".

@ -446,6 +446,17 @@
padding: 0;
}
/* make order table fill width */
#main table.bestelltable {
width: 100%;
}
.bestelltable .image_items .tdright {
padding-top: 6px !important;
}
.bestelltable .image_items .smallpreis {
margin-top: 6px;
}
/* hide or show business data form elements per default */
#main .data_business_hidden {
display: none;

@ -1575,7 +1575,7 @@ body.hp {
display: block;
text-align: right;
float: left;
padding: 4px 7px 0 0;
padding: 5px 4px 0 0;
width: 35px;
voice-family: "\"}\"";
voice-family:inherit;
@ -1601,7 +1601,7 @@ body.hp {
.okprodtext {
float: left;
margin: 0px;
padding: 6px 0 0 7px;
padding: 6px 0 0 4px;
}
.bestelltable {
border: none;
@ -1650,7 +1650,6 @@ body.hp {
.mysumme h3 {
color: #2C2C2C !important;
font-weight: bold !important;
padding-top: 3px !important;
}
.mysumme .smallpreis {
font-size: 14px;

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

@ -20,7 +20,7 @@
<h3>Telefonanlagen</h3>
<ul class="produktwahl">
<li>
<img src="/grafik_shop/pap2.gif" width="146" height="135" alt="PAP2T" />
<img src="/grafik_shop/PAP2T.gif" width="146" height="135" alt="PAP2T" />
<h4>PAP2 für einen Einzelanschluß<br />
<strong class="smallpreis">&euro; [% product_hash.PAP2T.price %]</strong></h4>
<form method="post" action="/shop/add_to_cart">
@ -41,7 +41,7 @@
</p>
</li>
<li>
<img src="/grafik_shop/spa90004.gif" width="146" height="135" alt="SPA9000" />
<img src="/grafik_shop/SPA9000_4.gif" width="146" height="135" alt="SPA9000" />
<h4>SPA9000 für<br/>
4 Nebenstellen<br />
<strong class="smallpreis">&euro; [% product_hash.SPA9000_4.price %]</strong></h4>
@ -63,7 +63,7 @@
</p>
</li>
<li>
<img src="/grafik_shop/spa900016.gif" width="146" height="135" alt="SPA9000" />
<img src="/grafik_shop/SPA9000_16.gif" width="146" height="135" alt="SPA9000" />
<h4>SPA9000 für<br/>
16 Nebenstellen<br />
<strong class="smallpreis">&euro; [% product_hash.SPA9000_16.price %]</strong></h4>
@ -84,7 +84,7 @@
</p>
</li>
<li class="last">
<img src="/grafik_shop/spa9000upgrade.gif" width="146" height="135" alt="SPA9000 upgrade" />
<img src="/grafik_shop/SPA9000_U.gif" width="146" height="135" alt="SPA9000 upgrade" />
<h4>SPA9000 Upgrade<br/>
von 4 auf 16 Nebenst.<br />
<strong class="smallpreis">&euro; [% product_hash.SPA9000_U.price %]</strong></h4>
@ -182,7 +182,7 @@
<h3>Telefone</h3>
<ul class="produktwahl">
<li>
<img src="/grafik_shop/spa921.gif" width="146" height="108" alt="SPA921" />
<img src="/grafik_shop/SPA921.gif" width="146" height="108" alt="SPA921" />
<h4>SPA921<br />
<strong class="smallpreis">&euro; [% product_hash.SPA921.price %]</strong></h4>
<form method="post" action="/shop/add_to_cart">
@ -203,7 +203,7 @@
</p>
</li>
<li>
<img src="/grafik_shop/spa922.gif" width="146" height="108" alt="SPA922" />
<img src="/grafik_shop/SPA922.gif" width="146" height="108" alt="SPA922" />
<h4>SPA922<br />
<strong class="smallpreis">&euro; [% product_hash.SPA922.price %]</strong></h4>
<form method="post" action="/shop/add_to_cart">
@ -224,7 +224,7 @@
</p>
</li>
<li>
<img src="/grafik_shop/spa941.gif" width="146" height="108" alt="SPA941" />
<img src="/grafik_shop/SPA941.gif" width="146" height="108" alt="SPA941" />
<h4>SPA941<br />
<strong class="smallpreis">&euro; [% product_hash.SPA941.price %]</strong></h4>
<form method="post" action="/shop/add_to_cart">
@ -244,7 +244,7 @@
</p>
</li>
<li class="last">
<img src="/grafik_shop/spa942.gif" width="146" height="108" alt="SPA942" />
<img src="/grafik_shop/SPA942.gif" width="146" height="108" alt="SPA942" />
<h4>SPA942<br />
<strong class="smallpreis">&euro; [% product_hash.SPA942.price %]</strong></h4>
<form method="post" action="/shop/add_to_cart">

@ -44,7 +44,7 @@
[% first = 1 %]
[% FOREACH ci = cart %]
<tr>
<tr class="image_items">
[% IF first %]
[% first = 0 %]
<td class="tdright">
@ -55,7 +55,7 @@
[% END %]
<td>
<strong class="okprodcount">[% ci.count %]x</strong>
<img class="okprodimg" src="" width="22" height="25" alt="" />
<img class="okprodimg" src="/grafik_shop/icon_[% ci.handle %].gif" width="22" height="25" alt="" />
<span class="okprodtext">[% ci.product %]</span>
</td>
<td>
@ -66,7 +66,7 @@
[% END %]
[% ELSE %] <!-- items from solutions workflow -->
<tr>
<tr class="image_items">
<td class="tdright">
<h3>Telefonanlage</h3>
</td>
@ -86,7 +86,7 @@
[% notfirst = 0 %]
[% FOREACH phone = phones %]
[% IF system.name || notfirst %]
<tr>
<tr class="image_items">
<td class="tdright" />
[% END %]
[% notfirst = notfirst + 1 %]
@ -122,7 +122,7 @@
<td class="tdright">
<h3>Versandkosten</h3>
</td>
<td>Hermes Paketversand, versicherte Sendung</td>
<td>Hermes Paketversand, [% shipping_weight %] kg</td>
<td><strong class="smallpreis">&euro;&nbsp;[% shipping_fee %]</strong></td>
<td><strong class="smallpreis">&euro;&nbsp;0.00</strong></td>
</tr>

@ -89,6 +89,7 @@
<div class="spalte2">
<p class="prodsumme">
EURO <strong>[% price_sum %]</strong>
</p>
<ul class="schritte">

Loading…
Cancel
Save