Post by wonderland » Wed May 17, 2017 7:15 pm

Hello,

I would like to pre-populate some fields when a user adds new address. Most of the clients are going to be companies and when Adding new delivery addresses some information like company name, copany id and VAT id, will always be the same and it would be great if these fields were already filled when adding a new address.

When editing any existing address, the fields are already pre-populated with the information that was added by user when he was registering, and I was hoping that the same could be done when adding new address.

After checking out controller file catalog/controller/account/address.php I thought that this might be the line of code that is responsible to pre-populating the fields with data:

Code: Select all

if (isset($this->request->post['company_id'])) {
	$this->data['company_id'] = $this->request->post['company_id'];
} elseif (!empty($address_info)) {
	$this->data['company_id'] = $address_info['company_id'];			
} else {
	$this->data['company_id'] = '';
}
If I understand correctly !empty is responsible for populating fields when a users edits existing address. So I tried doing this, in hopes that it would populate fields when adding the new address, unfortunately I get the variable undefined error.

Code: Select all

if (isset($this->request->post['company_id'])) {
	$this->data['company_id'] = $this->request->post['company_id'];
} elseif (!empty($address_info)) {
	$this->data['company_id'] = $address_info['company_id'];			
} else {
	$this->data['company_id'] = $address_info['company_id'];
}
Could you please suggest the correct way of doing this?

Newbie

Posts

Joined
Wed Jun 15, 2011 8:25 pm

Post by IP_CAM » Sat May 20, 2017 12:45 am

well, such could be changed, like in the register.tpl in the Theme Account Section,
by i.E. changing the Company INPUT VALUE variable <?php echo $company; ?>
to hardcoded content like: SAMPLE COMPANY
--
The code looks a little different from default 1.5.6-code, since I use a bootstrap Theme.
Change:

Code: Select all

<label class="control-label col-sm-3" for="company"><?php echo $entry_company; ?></label>
<div class="col-sm-6">
<input type="text" name="company" value="<?php echo $company; ?>" class="form-control" id="company">
</div>
to:

Code: Select all

<label class="control-label col-sm-3" for="company"><?php echo $entry_company; ?></label>
<div class="col-sm-6">
<input type="text" name="company" value="SAMPLE COMPANY" class="form-control" id="company">
</div>
Good Luck ;)
Ernie
---
Image

Attachments

hardcoded_company_variable.jpg

hardcoded_company_variable.jpg (41.44 KiB) Viewed 50 times


Ernie's OpenShop 1.75 with responsive Bootstrap Themes:
http://www.bigmax.ch - http://www.hitline.info - http://www.openshop.li
Image


User avatar
Newbie

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by wonderland » Tue May 23, 2017 5:44 pm

Hello,

Thank you very much for replying. It seems that you are on of the last OC 1.5 heroes :D

Your suggestion is great, but not quite what I need. I needed to pre-populate fields from an existing user data, when adding a new address. I was lucky enough to find a post which led me to solution. I ended up getting said data from database. Probably not the best solution, but still a solution.

Newbie

Posts

Joined
Wed Jun 15, 2011 8:25 pm
Who is online

Users browsing this forum: Bing [Bot] and 45 guests