Inheriting Address from Customer in Quote

Hi

I am trying to inherit the address from the customer in the quote (same as if one selects an account). Could somebody point me into the right direction on what I’m missing? I changed the AOS_Quotes/controller.php code in the the following way:

		if (isset($_REQUEST['contact_id'])) {
				$query = "SELECT * FROM contacts WHERE id = '{$_REQUEST['contact_id']}'";
            		
			$result = $this->bean->db->query($query, true);
			$row = $this->bean->db->fetchByAssoc($result);
			$this->bean->billing_contact_id = $row['id'];
			$this->bean->billing_contact = $row['first_name'].' '.$row['last_name'];
			// AML inherit address from contact		
			$this->bean->billing_address_street = $row['primary_address_street'];
			$this->bean->billing_address_city = $row['primary_address_city'];
			$this->bean->billing_address_state = $row['primary_address_state'];
			$this->bean->billing_address_postalcode = $row['primary_address_postalcode'];
			$this->bean->billing_address_country = $row['primary_address_country'];
			$this->bean->shipping_address_street = $row['primary_address_street'];
			$this->bean->shipping_address_city = $row['primary_address_city'];
			$this->bean->shipping_address_state = $row['primary_address_state'];
			$this->bean->shipping_address_postalcode = $row['primary_address_postalcode'];
			$this->bean->shipping_address_country = $row['primary_address_country'];
		}

Thanks
Adrian

I don’t know how to do this, but maybe I have a suggestion: instead of eediting the controller, how about a logic hook (or even a simple Workflow).

-When the Customer address is changed, grab the address and put it in every quote

or

  • when the quote is created, go to the Customer and grab the address

Maybe I didn’t explain it well enough. In the quote module, when you select the contact, I would like the shipping address to be filled with the contact’s address and not the accounts as it currently is. I attached a screenshot to this post to visualize this. Is the AOS_Quotes/controller.php not the correct place for this?

Oh, I understand better now, sorry.

You didn’t say what happens with your code, do you get an error, empty fields, what?

The fields just stay empty. If I select an account, the address is filled, but with a customer they stay empty. I also attached the whole controller.php from AOS_Quotes.

Thanks

Does the first name and last name populate correctly?

Maybe this code only puts the data into the bean, maybe it needs to be made (some other place) to load the bean in to the screen fields. if you can find a place where it does that for the first name and last name, stored in $this->bean->billing_contact, then you can add the other fields there.

But I’m not sure you’ll find it, maybe a more generic mechanism is at work there…

1 Like

I searched for hours, sadly no luck. I deleted every billing_contact one by one in the quote module php files, with various effects, however the field always filled (except when it was no longer present at all).

With more research I tried to populate it by adding the following to the viewdefs.php in the quotes module, however its not working either.

Thanks for the guidance!


array (
	'name' => 'billing_contact',
	'studio' => 'visible',
	'label' => 'LBL_billing_contact',
	'displayParams' => array (
		'field_to_name_array' => array(
			'id'=>'billing_contact_id', 
			'name' => 'billing_contact',
			'primary_address_street' => 'billing_address_street',
		),
	),
),