Created
July 14, 2015 08:46
-
-
Save d-bo/f4cadae1a1e3b78d2859 to your computer and use it in GitHub Desktop.
Calc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Калькулятор доставки</title> | |
</head> | |
<body> | |
<form action="/" method="get"> | |
<?php | |
$token = '11570.pbpqebfc'; | |
if ($_GET['target'] && $_GET['weight'] && $_GET['ordersum']) { | |
$url = 'http://api.boxberry.de/json.php?token=' . $token . '&method=DeliveryCosts&weight=' . $_GET['weight'] . '&target=' . $_GET['target'] . '&ordersum=0&deliverysum=0&paysum=0'; | |
$handle = fopen($url, "rb"); | |
$contents = stream_get_contents($handle); | |
fclose($handle); | |
$data = json_decode($contents,true); | |
if (count($data)<=0 or $data[0]['err']) { | |
echo $data[0]['err']; | |
} else { | |
echo '<p>price: <b>' . $data['price'] . '</b><p>'; | |
echo '<p>price base: <b>' . $data['price_base'] . '</b><p>'; | |
echo '<p>price service: <b>' . $data['price_service'] . '</b><p>'; | |
echo '<p>delivery period: <b>' . $data['delivery_period'] . '</b><p>'; | |
} | |
echo '<p><a href="/">Вернуться</a></p>'; | |
exit; | |
} | |
$url = 'http://api.boxberry.de/json.php?token=' . $token . '&method=ListCities'; | |
$handle = fopen($url, "rb"); | |
$contents = stream_get_contents($handle); | |
fclose($handle); | |
$data = json_decode($contents,true); | |
if (count($data)<=0 or $data[0]['err']) { | |
echo $data[0]['err']; | |
echo '<p><a href="/">Вернуться</a></p>'; | |
exit; | |
} else { | |
echo '<select name="target">'; | |
foreach ($data as $k => $v) { | |
echo '<option value="' . $data[$k]['Code'] . '">' . $data[$k]['Name'] . '</option>'; | |
} | |
echo '</select>'; | |
} | |
?> | |
<p> | |
<h3>Вес товара</h3> | |
<input type="text" name="weight"> | |
</p> | |
<p> | |
<h3>Стоимость товара</h3> | |
<input type="text" name="ordersum"> | |
</p> | |
<p> | |
<input type="submit" value="Рассчитать"> | |
</p> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment