Answer the question
In order to leave comments, you need to log in
How to set up delivery calculation for API 2.0 from Nova Poshta?
Can you please tell me how to set up the delivery calculation for API 2.0 from Nova Poshta? (the site itself is in php and mysql).
1) I registered in the account of New Mail itself, I received the Api key.
2) I found a ready-made class on Github ( https://github.com/lis-dev/nova-poshta-api-2).
3) How can I display on the page, for example, a form with the point of departure, the point of receipt and the price for delivery? Give, please, at least a direction where to dig...
UPd 02/19/17
On the advice of the respected sim3x, I dug into the documentation of "Novaya Poshta", tried to create json for a request to their API.
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Пример отправки (Новая почта)</title>
</head>
<body>
<div class='citySender'></div>
<div class='cityRecipient'></div>
<div class='weight'></div>
<div class='cost'></div>
</body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script>
$(function () {
var params = {
'apiKey': 'Ключ АПИ, который я вставил',
'modelName': 'InternetDocument',
'calledMethod': 'getDocumentPrice',
'methodProperties': {
'CitySender': '8d5a980d-391c-11dd-90d9-001a92567626',
'CityRecipient': 'db5c88e0-391c-11dd-90d9-001a92567626',
'Weight': '1',
'ServiceType': 'DoorsDoors',
'Cost': '400',
'CargoType': 'Documents',
'SeatsAmount': '1',
'PackCalculate': {
'PackCount': '1',
'PackRef': '1499fa4a-d26e-11e1-95e4-0026b97ed48a'
},
'RedeliveryCalculate': {
'CargoType': 'Money',
'Amount': '100'
}
}
};
$.ajax({
url: 'https://api.novaposhta.ua/v2.0/json/?' + $.param(params),
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader('Content-Type', 'application/json');
},
type: 'POST',
dataType: 'jsonp',
data: '{body}'
}).done(function (jsondb) {
$('.citySender').html('Город отправитель: ' + jsondb.data[0].CitySender) // город отправитель
$('.cityRecipient').html('Город получатель: ' + jsondb.data[0].CityRecipient) // город получатель
$('.weight').html('Вес: ' + jsondb.data[0].Weight + ' кг.') // вес
$('.cost').html('Стоимость: ' + jsondb.data[0].Cost + ' грн.') // стоимость
}).fail(function () {
alert('error');
});
});
</script>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question