R
R
Roman-OverOffers2014-05-24 11:02:45
PHP
Roman-OverOffers, 2014-05-24 11:02:45

How to substitute different data in JS depending on the GET parameter?

How can I substitute the date into the ids from the json library depending on the parameter received in the URL
?country_code=RU

There is such a library with a date for different countries

$jsonData = {"product":{"id":314,"title":"Заголовок","short_description":"Описание","full_description":"Полное описание."},"prices":{"270":{"price":290,"old_price":600,"delivery_price":30,"tax_price":0,"upsale_price":0,"geo_key":"UA","name":"Украина","currency":"грн.","rate":0.37,"phone_template":"+38 067 927 25 74","address_template":"01024, г. Киев, ул. Богомольца, д.5, кв.9","name_template":"Карпенко Ярослав Федорович","active":true},"271":{"price":999,"old_price":2000,"delivery_price":281,"tax_price":0,"upsale_price":0,"geo_key":"RU","name":"Россия","currency":"руб.","rate":1,"phone_template":"+7 928 827-22-53","address_template":"135999, Москва, ул. Ленина, д.10, кв.5","name_template":"Петров Петр Петрович","active":false},"272":{"price":5635,"old_price":11000,"delivery_price":920,"tax_price":0,"upsale_price":0,"geo_key":"KZ","name":"Казахстан","currency":"тенге","rate":5.3,"phone_template":"+7 705 1301111","address_template":"ул. Майлина, д.3, кв. 6, г. Костанай, 110003","name_template":"Алтынбаев Азат Тюлегенович","active":false},"346":{"price":400,"old_price":800,"delivery_price":40,"tax_price":0,"upsale_price":0,"geo_key":"MD","name":"Молдова","currency":"лей","rate":0.394,"phone_template":"+37 379 392 25 84","address_template":"MD-2012, Кишинев, ул. Армянская, д. 14, кв. 1","name_template":"Леонид Поторак","active":false},"357":{"price":350000,"old_price":700000,"delivery_price":40000,"tax_price":0,"upsale_price":0,"geo_key":"BY","name":"Беларусь","currency":"бел. руб.","rate":280,"phone_template":"+37 529 186 24 65","address_template":"220035, г. Минск, пр-т Машерова, д. 76, кв. 17","name_template":"Матвеев Евгений Алексеевич","active":false}},"lowPrice":{"year":"2014","month":"05","day":"25"}};


As I understand it, you need to get GET in php and then do json_decode($country_code)
How now to connect with geo_key == $country_code and display only the date for this country throughout the site?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mykola, 2014-05-24
@iSensetivity

$country_code = $_GET['country_code']; // get the variable from the link
$jsonData = //your array.
$jsonData = json_decode($jsonData); //decode into an object.
$geo = $jsonData->product->prices->270->geo_key; // get the country code from the array.
//then compare and output
PS your json array is invalid.

R
Roman-OverOffers, 2014-05-24
@Roman-OverOffers

My array is written in javascript as I understand it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question