Post by alan_wheeler » Fri Dec 16, 2011 7:23 am

I have managed to carry out my own mod so that the store address is used to produce a google map with the overlay marker box showing the full address.

Now what I want to do is ideally create an extra field in the adming->settings just to insert the postcode so I can use this info on its own to geocode the postcode to LAT, LONG coordinates.

Any suggestions on how to alter the admin end to take an extra field for just postcode?

Newbie

Posts

Joined
Tue Dec 13, 2011 6:27 am

Post by dansmithpm » Fri Dec 16, 2011 9:56 pm

ignore this one, have added post below with factual detail !!
Last edited by dansmithpm on Fri Dec 16, 2011 10:30 pm, edited 1 time in total.

Newbie

Posts

Joined
Fri Dec 16, 2011 9:15 pm

Post by dansmithpm » Fri Dec 16, 2011 10:29 pm

Had a dig a little deeper, this seems to work:

Do the admin side first:

in the admin\language\english\setting\setting.php add

Code: Select all

$_['entry_postcode']            = 'Postcode:';
In the controller at admin\controller\setting\setting.php

add a line near the top and add an entry to the language file for postcode

Code: Select all

		$this->data['entry_postcode'] = $this->language->get('entry_postcode');
you can copy one of the sections such as below (round about line 279 in my copy) to get/set

Code: Select all

		if (isset($this->request->post['config_postcode'])) {
			$this->data['config_postcode'] = $this->request->post['config_postcode'];
		} else {
			$this->data['config_postcode'] = $this->config->get('config_postcode');
		}
in admin\view\template\setting.php add the field to display/edit, again can copy

Code: Select all

              <td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
              <td><input type="text" name="config_postcode" value="<?php echo $config_postcode; ?>" size="40" />
                <?php if ($error_postcode) { ?>
                <span class="error"><?php echo $error_postcode; ?></span>
                <?php } ?></td>
            </tr>
Now the front end:

in catalog\controller\information\contact.php, add (around line48 )

Code: Select all

    	$this->data['postcode'] = $this->config->get('config_postcode');		
to add postcode onto the end of the address block, in catalog\view\your-template\information\contact.tpl, add a line (round about line 16)

Code: Select all

        <?php echo $postcode; ?>
Think that's about it, works for me!

Newbie

Posts

Joined
Fri Dec 16, 2011 9:15 pm

Post by straightlight » Sat Dec 17, 2011 1:52 am

I don't recommend doing it this way since modules can be build alternatively as a purpose of avoiding to modify core files. Additionally, the store ID can already be set as a parameter within the editSetting method.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 4 guests