Jump to content

Get addresses data in json


Recommended Posts



I need to get the customers' addresses in json format. I tried to override the AdressesController by adding 

if(Tools::getValue("format") == "json")
	$_POST["addresses"] = Tools::jsonEncode($multiple_addresses_formated);

and in the tpl

	  	type: "POST",
	  	url: "http://localhost/index.php?controller=addresses&id_address="+$(this).attr('id')+"&format=json",
	  	success: function(addrjson){

The request works but it return the whole page (with the header, footer, etc...).


Does anybody knows how to only retrieve the addresses json object ?



Share this post

Link to post
Share on other sites



Sorry I forgot to say that I putted it in the inirContent() function.


I have modify my code and it seems to work

if(Tools::getValue("format") == "json") {
	if(Tools::getValue("id_address")) {
		$id_address = Tools::getValue("id_address");
		$address = new Address($id_address);
		$json_address = AddressFormat::getFormattedLayoutData($address);
		$json_address["formated"]["id_address"] = $id_address;

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More