Browse Source

Add automatic shipping costs determination

Shipping costs are now automatically determined based on the country selected in the address. At the same time, the numbers were adapted to our real costs, and also we now only differ between within Germany and worldwide.

Fixes #877
pull/1060/head
Reinhard Müller 2 weeks ago
parent
commit
46545576be
8 changed files with 200 additions and 227 deletions
  1. 21
    4
      cgi-bin/weborder.pl
  2. 26
    41
      order/order.de.xhtml
  3. 20
    35
      order/order.en.xhtml
  4. 21
    35
      order/order.it.xhtml
  5. 102
    112
      order/order.nl.xhtml
  6. 1
    0
      order/order.sources
  7. 9
    0
      order/order.xsl
  8. BIN
      templates/invoice.odt

+ 21
- 4
cgi-bin/weborder.pl View File

@@ -39,12 +39,23 @@ if ($query->param("url")) {

my $name = decode("utf-8", $query->param("name"));
my $address = decode("utf-8", $query->param("address"));
my $country = $query->param("country");
my ($country_code, $country_name) = split /\|/, $country;
my $email = decode("utf-8", $query->param("email"));
my $phone = decode("utf-8", $query->param("phone"));
my $language = $query->param("language");

# Determine shipping fees based on country code from drop-down list
my $shipping;

if ($country_code == 'DE') {
$shipping = 5;
} else {
$shipping = 8;
}

# Remove all parameters except for items and prices.
$query->delete("url", "name", "address", "email", "phone", "language");
$query->delete("url", "name", "address", "country", "email", "phone", "language");

my $lang = substr $language, 0, 2;

@@ -76,7 +87,9 @@ foreach $item ($query->param) {
}
}

if ($count < 2) {
$amount += $shipping;

if ($count < 1) {
print "Content-type: text/html\n\n";
print "<p>No items selected!</p>\n";
exit;
@@ -106,7 +119,7 @@ my $reference = "MP" . $date . (substr $time, -4) . (sprintf "%03u", $amount);
# Compile email text
# -----------------------------------------------------------------------------

my $body = "$name\n$address\nPhone: $phone\n\n";
my $body = "$name\n$address\n$country_name\nPhone: $phone\n\n";

foreach $item ($query->param) {
$value = $query->param($item);
@@ -116,8 +129,9 @@ foreach $item ($query->param) {
}
}

$body .= sprintf "Shipping to %-30s %6.2f\n", $country_name, $shipping;
$body .= "---------------------------------------------------\n";
$body .= sprintf("Total amount € %6.2f\n", $amount);
$body .= sprintf "Total amount € %6.2f\n", $amount;
$body .= "===================================================\n";

# -----------------------------------------------------------------------------
@@ -139,6 +153,7 @@ push @odtfill, "/tmp/invoice.odt";
push @odtfill, "repeat=" . $count;
push @odtfill, "Name=" . $name;
push @odtfill, "Address=" . $address =~ s/\n/\\n/gr;
push @odtfill, "Country=" . $country_name;
foreach $item ($query->param) {
$value = $query->param($item);
if (not $item =~ /^_/ and $value) {
@@ -148,6 +163,8 @@ foreach $item ($query->param) {
push @odtfill, "Amount=" . sprintf "%.2f", $value * $price;
}
}
push @odtfill, "Country=" . $country_name; # 2nd Country placeholder
push @odtfill, "Shipping=" . sprintf "%.2f", $shipping;
push @odtfill, "Total=" . $amount_f;
push @odtfill, "Net=" . $net;
push @odtfill, "Vat=" . $vat;

+ 26
- 41
order/order.de.xhtml View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8"?>

<html>
<head>
<title>Fanartikel – FSFE</title>
<style type="text/css">
div#toc {
float: right;
@@ -27,7 +27,7 @@

<body class="toplevel">
<h1>Fanartikel</h1>
<div id="toc">
<p style="text-indent:1em;">Kategorien:</p>
<ul style="margin-bottom: 1em;">
@@ -46,7 +46,7 @@
Bewusstsein zu bringen. Mit jedem Kauf unterstützen Sie wichtige
Projekte der FSFE.
</p>
<p>
Um die genauen Maße zu erhalten, bewegen Sie den Mauszeiger über die Größenangaben oder
sehen Sie in der <a href="size.html">Größentabelle</a> nach.
@@ -56,19 +56,19 @@

<form action="/cgi-bin/weborder.pl" method="post" class="item-grid">
<h2 id="tshirt">T-Shirts</h2>
<dynamic-content type="tshirt"/>

<h2 id="girlie">Damen-T-Shirts</h2>
<dynamic-content type="girlie"/>

<h2 id="hooded">Kapuzenshirts</h2>
<dynamic-content type="hooded"/>

<!-- h2 id="baby-clothes">Babykleidung</h2>
<dynamic-content type="baby-clothes"/ -->

<h2 id="other">Andere Artikel</h2>
@@ -76,7 +76,7 @@
<dynamic-content type="other"/>

<h2>Infomaterial</h2>
<p>
Auf unserer
<a href="/contribute/spreadtheword.html#promo-material">Informationsmaterial-Seite</a>
@@ -85,57 +85,44 @@

<h2>Versand</h2>

<input type="hidden" name="shipping" value="1"/>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-de" value="3" />
<strong>Versand innerhalb Deutschlands (€3.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-eu" value="7" checked="" />
<strong>Versand innerhalb Europas (€7.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-world" value="12" />
<strong>Versand außerhalb Europas (€12.00)</strong>
</label>
</div>
<p>The following shipping fees apply:</p>
<ul>
<li>Shipping within Germany: €5.00</li>
<li>Shipping worldwide: €8.00</li>
</ul>

<h2>Ihre Daten</h2>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="name">Name:</label>
</div>
<label class="col-sm-2 control-label" for="name">Name:</label>
<div class="col-sm-4">
<input class="form-control" id="name" name="name" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label vcenter" for="address">Vollständige Adresse:</label>
</div>
<label class="col-sm-2 control-label" for="address">Adresse:</label>
<div class="col-sm-4">
<textarea class="form-control" rows="5" id="address" name="address" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="email">E-Mail:</label>
<label class="col-sm-2 control-label" for="address">Land:</label>
<div class="col-sm-4">
<country-list />
</div>
</div>

<div class="row form-group">
<label class="col-sm-2 control-label" for="email">E-Mail:</label>
<div class="col-sm-4">
<input class="form-control" id="email" name="email" type="email" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="phone">Telefon:</label>
</div>
<label class="col-sm-2 control-label" for="phone">Telefon:</label>
<div class="col-sm-4">
<input class="form-control" id="phone" name="phone" type="text" />
</div>
@@ -162,8 +149,6 @@
wenn Sie die Bestellung abgeschickt haben.
</p>
</body>

<timestamp>$Date$ $Author$</timestamp>
</html>
<!--
Local Variables: ***

+ 20
- 35
order/order.en.xhtml View File

@@ -3,7 +3,7 @@
<html>
<head>
<title>Merchandise – FSFE</title>
<style type="text/css">
div#toc {
float: right;
@@ -44,7 +44,7 @@
below. Free Software clothing is a great way of raising awareness within
your local community, and each sale helps to fund critical FSFE projects.
</p>
<p>
To get detailed information about the actual dimensions of the various
sizes of the clothes, place your mouse pointer over the size label or
@@ -79,62 +79,49 @@
<p>
Check our
<a href="/contribute/spreadtheword.html#promo-material">order page for information material</a>
to order leaflets, stickers and other things.
to order leaflets, stickers and other things.
</p>

<h2>Shipping</h2>

<input type="hidden" name="shipping" value="1"/>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-de" value="3" />
<strong>Shipping within Germany (€3.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-eu" value="7" checked="" />
<strong>Shipping within Europe (€7.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-world" value="12" />
<strong>Shipping outside Europe (€12.00)</strong>
</label>
</div>
<p>The following shipping fees apply:</p>
<ul>
<li>Shipping within Germany: €5.00</li>
<li>Shipping worldwide: €8.00</li>
</ul>

<h2>Your Data</h2>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="name">Name:</label>
</div>
<label class="col-sm-2 control-label" for="name">Name:</label>
<div class="col-sm-4">
<input class="form-control" id="name" name="name" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label vcenter" for="address">Complete address:</label>
</div>
<label class="col-sm-2 control-label" for="address">Address:</label>
<div class="col-sm-4">
<textarea class="form-control" rows="5" id="address" name="address" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="email">Email:</label>
<label class="col-sm-2 control-label" for="address">Country:</label>
<div class="col-sm-4">
<country-list />
</div>
</div>

<div class="row form-group">
<label class="col-sm-2 control-label" for="email">Email:</label>
<div class="col-sm-4">
<input class="form-control" id="email" name="email" type="email" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="phone">Phone:</label>
</div>
<label class="col-sm-2 control-label" for="phone">Phone:</label>
<div class="col-sm-4">
<input class="form-control" id="phone" name="phone" type="text" />
</div>
@@ -160,8 +147,6 @@
cards. You will receive further information upon submission of your order.
</p>
</body>

<timestamp>$Date$ $Author$</timestamp>
</html>
<!--
Local Variables: ***

+ 21
- 35
order/order.it.xhtml View File

@@ -3,7 +3,7 @@
<html>
<head>
<title>Prodotti – FSFE</title>
<style type="text/css">
div#toc {
float: right;
@@ -41,10 +41,10 @@

<p class="p-summary">
Mostra il tuo amore per il Software Libero usando e indossando i nostri prodotti.
I vestiti Software Libero sono un buon modo per far conoscere i nostri principi
I vestiti Software Libero sono un buon modo per far conoscere i nostri principi
nella zona in cui vivi, e inoltre ogni acquisto finanzia i progetti della FSFE.
</p>
<p>
Per ottenere informazioni dettagliate sulle dimensioni effettive degli abiti
posiziona il puntatore del mouse sui codici delle taglie (S, M, ecc...) oppure
@@ -79,62 +79,49 @@
<p>
Visita la pagina del
<a href="/contribute/spreadtheword.html#promo-material">materiale informativo</a>
per consultare e richiedere volantini, adesivi e altro materiale.
per consultare e richiedere volantini, adesivi e altro materiale.
</p>

<h2>Spedizione</h2>

<input type="hidden" name="shipping" value="1"/>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-de" value="3" />
<strong>Spedizione in Germania (3,00 €)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-eu" value="7" checked="" />
<strong>Spedizione in Europa (7,00 €)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-world" value="12" />
<strong>Spedizione extra UE (12,00 €)</strong>
</label>
</div>
<p>Si applicano le seguenti spese di spedizione:</p>
<ul>
<li>Spedizione in Germania: €5.00</li>
<li>Spedizione nel mondo intero: €8.00</li>
</ul>

<h2>I tuoi dati</h2>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="name">Nome:</label>
</div>
<label class="col-sm-2 control-label" for="name">Nome:</label>
<div class="col-sm-4">
<input class="form-control" id="name" name="name" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label vcenter" for="address">Indirizzo:</label>
</div>
<label class="col-sm-2 control-label" for="address">Indirizzo:</label>
<div class="col-sm-4">
<textarea class="form-control" rows="5" id="address" name="address" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="email">Email:</label>
<label class="col-sm-2 control-label" for="address">Paese:</label>
<div class="col-sm-4">
<country-list />
</div>
</div>

<div class="row form-group">
<label class="col-sm-2 control-label" for="email">Email:</label>
<div class="col-sm-4">
<input class="form-control" id="email" name="email" type="email" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="phone">Telefono:</label>
</div>
<label class="col-sm-2 control-label" for="phone">Telefono:</label>
<div class="col-sm-4">
<input class="form-control" id="phone" name="phone" type="text" />
</div>
@@ -161,7 +148,6 @@
</p>
</body>

<timestamp>$Date$ $Author$</timestamp>
<translator>Stefano Fraccaro e Sebastiano Pistore</translator>
</html>
<!--

+ 102
- 112
order/order.nl.xhtml View File

@@ -1,139 +1,129 @@
<?xml version="1.0" encoding="UTF-8" ?>

<html>
<head>
<title>Fan-artikelen – FSFE</title>
<style type="text/css">
div#toc {
float: right;
clear: right;
border: solid 1px;
margin: .5em;
background: rgb(240,240,240);
width: 30%;
}

@media only screen and (max-width: 600px) {
div#toc {
width: 100%;
}
}
</style>
<meta name="description" content="Toon uw liefde voor Vrije Software door de FSFE-fanartikelen te gebruiken en te dragen." />
<meta name="keywords" content="winkel bestel t-shirt shirts hoodie artikelen fan-artikelen promoot magneet tas slab pin verzenden kopen post betaling" />
<meta name="image" content="https://fsfe.org/graphics/tshirt-promo-800px.jpg" />
</head>

<body class="toplevel">
<h1>Fan-artikelen</h1>

<div id="toc">
<p style="text-indent:1em;">Beschikbare fan-artikelen:</p>
<ul style="margin-bottom: 1em;">
<li><a href="#tshirt">T-Shirts</a></li>
<li><a href="#girlie">T-Shirts voor dames</a></li>
<li><a href="#hooded">Shirts met kap (hoodies)</a></li>
<!-- li><a href="#baby-clothes">Babykleding</a></li -->
<li><a href="#other">Andere artikelen</a></li>
</ul>
</div>
<?xml version="1.0" encoding="UTF-8"?>

<html>
<head>
<title>Fan-artikelen – FSFE</title>

<style type="text/css">
div#toc {
float: right;
clear: right;
border: solid 1px;
margin: .5em;
background: rgb(240,240,240);
width: 30%;
}

@media only screen and (max-width: 600px) {
div#toc {
width: 100%;
}
}
</style>
<meta name="description" content="Toon uw liefde voor Vrije Software door de FSFE-fanartikelen te gebruiken en te dragen." />
<meta name="keywords" content="winkel bestel t-shirt shirts hoodie artikelen fan-artikelen promoot magneet tas slab pin verzenden kopen post betaling" />
<meta name="image" content="https://fsfe.org/graphics/tshirt-promo-800px.jpg" />
</head>

<body class="toplevel">
<h1>Fan-artikelen</h1>

<p class="p-summary">
Toon uw liefde voor Vrije Software door de fan-artikelen hieronder te
gebruiken en te dragen. Het dragen van Vrije Software-kleding is een goede
manier om het bewustzijn in uw lokale gemeenschap te vergroten en iedere
verkoop helpt om cruciale FSFE-projecten te financieren.
</p>
<p>
Plaats voor gedetailleerde informatie over de werkelijke dimensies van de verschillende kledingformaten uw muiscursor over het kledingformaat of bekijk de <a href="size.html">maattabel</a>.
</p>
<p style="clear:both;"></p>
<div id="toc">
<p style="text-indent:1em;">Beschikbare fan-artikelen:</p>
<ul style="margin-bottom: 1em;">
<li><a href="#tshirt">T-Shirts</a></li>
<li><a href="#girlie">T-Shirts voor dames</a></li>
<li><a href="#hooded">Shirts met kap (hoodies)</a></li>
<!-- li><a href="#baby-clothes">Babykleding</a></li -->
<li><a href="#other">Andere artikelen</a></li>
</ul>
</div>

<p class="p-summary">
Toon uw liefde voor Vrije Software door de fan-artikelen hieronder te
gebruiken en te dragen. Het dragen van Vrije Software-kleding is een goede
manier om het bewustzijn in uw lokale gemeenschap te vergroten en iedere
verkoop helpt om cruciale FSFE-projecten te financieren.
</p>

<form action="/cgi-bin/weborder.pl" method="post" class="item-grid">
<h2 id="tshirt">T-Shirts</h2>
<p>
Plaats voor gedetailleerde informatie over de werkelijke dimensies van de
verschillende kledingformaten uw muiscursor over het kledingformaat of
bekijk de <a href="size.html">maattabel</a>.
</p>

<dynamic-content type="tshirt"/>
<p style="clear:both;"></p>

<h2 id="girlie">T-Shirts voor dames</h2>

<dynamic-content type="girlie"/>
<form action="/cgi-bin/weborder.pl" method="post" class="item-grid">
<h2 id="tshirt">T-Shirts</h2>

<h2 id="hooded">Shirts met kap (hoodies)</h2>
<dynamic-content type="tshirt"/>

<dynamic-content type="hooded"/>
<h2 id="girlie">T-Shirts voor dames</h2>

<!-- h2 id="baby-clothes">Babykleding</h2>
<dynamic-content type="girlie"/>

<dynamic-content type="baby-clothes"/ -->
<h2 id="hooded">Shirts met kap (hoodies)</h2>

<h2 id="other">Andere artikelen</h2>
<dynamic-content type="hooded"/>

<dynamic-content type="other"/>
<!-- h2 id="baby-clothes">Babykleding</h2>

<h2>Promotiematerialen</h2>
<dynamic-content type="baby-clothes"/ -->

<p>
Bekijk onze <a href="/contribute/spreadtheword.html#promo-material">bestelpagina
om informatiematerialen</a> zoals folders en stickers te bestellen.
</p>
<h2 id="other">Andere artikelen</h2>

<dynamic-content type="other"/>

<h2>Promotiematerialen</h2>

<p>
Bekijk onze
<a href="/contribute/spreadtheword.html#promo-material">bestelpagina om informatiematerialen</a>
zoals folders en stickers te bestellen.
</p>

<h2>Verzenden</h2>

<input type="hidden" name="shipping" value="1"/>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-de" value="3" />
<strong>Verzenden binnen Duitsland (€3.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-eu" value="7" checked="" />
<strong>Verzenden binnen Europa (€7.00)</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="_shipping" id="shipping-world" value="12" />
<strong>Verzenden buiten Europa (€12.00)</strong>
</label>
</div>
<p>De volgende verzendkosten zijn van toepassing:</p>
<ul>
<li>Verzending binnen Duitsland: €5.00</li>
<li>Wereldwijd verzenden: €8.00</li>
</ul>

<h2>Je gegevens</h2>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="name">naam:</label>
</div>
<label class="col-sm-2 control-label" for="name">naam:</label>
<div class="col-sm-4">
<input class="form-control" id="name" name="name" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label vcenter" for="address">Compleet adres:</label>
</div>
<label class="col-sm-2 control-label" for="address">Adres:</label>
<div class="col-sm-4">
<textarea class="form-control" rows="5" id="address" name="address" type="text" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="email">E-mail:</label>
<label class="col-sm-2 control-label" for="address">Land:</label>
<div class="col-sm-4">
<country-list />
</div>
</div>

<div class="row form-group">
<label class="col-sm-2 control-label" for="email">E-mail:</label>
<div class="col-sm-4">
<input class="form-control" id="email" name="email" type="email" />
</div>
</div>

<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" for="phone">Telefoon:</label>
</div>
<label class="col-sm-2 control-label" for="phone">Telefoon:</label>
<div class="col-sm-4">
<input class="form-control" id="phone" name="phone" type="text" />
</div>
@@ -154,17 +144,17 @@ Toon uw liefde voor Vrije Software door de fan-artikelen hieronder te
</div>
</form>

<p>
Betaling is mogelijk via bankoverschrijving, PayPal en verschillende
credit- en debitcards. U ontvangt verdere informatie na het plaatsen van uw bestelling.
</p>
</body>
<timestamp>$Date$ $Author$</timestamp>
<translator>André Ockers</translator>
</html>
<!--
Local Variables: ***
mode: xml ***
End: ***
-->
<p>
Betaling is mogelijk via bankoverschrijving, PayPal en verschillende
credit- en debitcards. U ontvangt verdere informatie na het plaatsen
van uw bestelling.
</p>
</body>
<translator>André Ockers</translator>
</html>
<!--
Local Variables: ***
mode: xml ***
End: ***
-->

+ 1
- 0
order/order.sources View File

@@ -1,2 +1,3 @@
order/*/item:[]
order/*/info:[]
tools/countries:[]

+ 9
- 0
order/order.xsl View File

@@ -1,6 +1,7 @@
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="../tools/xsltsl/countries.xsl" />
<xsl:import href="../fsfe.xsl" />

<!-- Fill dynamic content -->
@@ -150,4 +151,12 @@
</xsl:element>
</xsl:template>

<!-- Dropdown list of countries requiring a choice -->
<xsl:template match="country-list">
<xsl:call-template name="country-list">
<xsl:with-param name="class" select="'form-control'"/>
<xsl:with-param name="required" select="'yes'"/>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>

BIN
templates/invoice.odt View File


Loading…
Cancel
Save