diff --git a/Helper/Data.php b/Helper/Data.php
index 1e949249..ae2baff7 100644
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -148,11 +148,21 @@ public function usesAutocomplete(
);
}
- public function populateOrganisation(
+ public function removeOrganisation(
$scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $storeId = null
) {
return $this->scopeConfig->isSetFlag(
- 'idealpostcodes/settings/populate_organisation',
+ 'idealpostcodes/settings/remove_organisation_store',
+ $scope,
+ $storeId
+ );
+ }
+
+ public function removeOrganisationAdmin(
+ $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $storeId = null
+ ) {
+ return $this->scopeConfig->isSetFlag(
+ 'idealpostcodes/settings/remove_organisation_admin',
$scope,
$storeId
);
@@ -210,7 +220,7 @@ public function toConfiguration(
'api_key' => $this->getApiKey($scope, $storeId),
'postcodeLookup' => $this->usesPostcodeLookup($scope, $storeId),
'addressAutocomplete' => $this->usesAutocomplete($scope, $storeId),
- 'populateOrganisation' => $this->populateOrganisation($scope, $storeId),
+ 'removeOrganisation' => $this->removeOrganisation($scope, $storeId),
'hoistCountryField' => $this->hoistCountry($scope, $storeId),
'requireCounty' => $this->requireCounty($scope, $storeId),
'autocompleteOverride' => $this->getAutocompleteOverride($scope, $storeId),
@@ -229,9 +239,10 @@ public function toAdminConfiguration(
'enabled' => $this->isEnabled($scope),
'api_key' => $this->getApiKey($scope),
'addressAutocomplete' => $this->isEnabledAdminAutocomplete($scope),
- 'populateOrganisation' => $this->populateOrganisation($scope),
+ 'removeOrganisation' => $this->removeOrganisationAdmin($scope),
'hoistCountryField' => $this->hoistCountry($scope),
- 'requireCounty' => $this->requireCounty($scope)
+ 'requireCounty' => $this->requireCounty($scope),
+ "customFields" => $this->customFields($scope),
);
return $config;
}
diff --git a/lib/extension.ts b/lib/extension.ts
index 0afdcb87..a5f65f58 100644
--- a/lib/extension.ts
+++ b/lib/extension.ts
@@ -23,6 +23,7 @@ import { PostcodeLookup } from "@ideal-postcodes/postcode-lookup";
export interface Config extends BaseConfig {
hoistCountry?: boolean;
+ removeOrganisation: boolean;
customFields?: OutputFields[];
}
@@ -160,6 +161,8 @@ export const setupPostcodeLookup = (
checkKey: true,
context: "div.idpc_lookup",
outputFields,
+ removeOrganisation: config.removeOrganisation,
+ populateCounty: config.populateCounty,
selectStyle: {
"margin-top": "5px",
"margin-bottom": "5px",
@@ -223,6 +226,8 @@ export const setupAutocomplete = async (
{
apiKey: config.apiKey,
checkKey: true,
+ removeOrganisation: config.removeOrganisation,
+ populateCounty: config.populateCounty,
onLoaded() {
//@ts-expect-error
this.options.outputFields = getFields(outputFields, this.scope);
diff --git a/view/adminhtml/templates/admin.phtml b/view/adminhtml/templates/admin.phtml
index a29daf93..90bbded6 100644
--- a/view/adminhtml/templates/admin.phtml
+++ b/view/adminhtml/templates/admin.phtml
@@ -1,28 +1,51 @@
helper('Idealpostcodes\Ukaddresssearch\Helper\Data');
-
-$script = '
-document.addEventListener(\'DOMContentLoaded\', function() {
- var apiKey = "' . $helper->getConfig('api_key') . '";
- var autocomplete = ' . $helper->getConfig('addressAutocomplete') . ';
- var removeOrganisation = ' . $helper->getConfig('removeOrganisation') . ';
- var populateCounty = ' . $helper->getConfig('requireCounty') . ';
- var enabled = ' . $helper->getConfig('enabled') . ';
- var customFields = ' . trim(preg_replace("/\r|\n/", "", $helper->getConfig('customFields'))) . ';
- // Exit early if disabled
- if (enabled === false) return;
- window.idpcConfig = {
- apiKey: apiKey,
- postcodeLookup: false,
- autocomplete: autocomplete,
- populateCounty: populateCounty,
- removeOrganisation: removeOrganisation,
- hoistCountry: false,
- customFields: customFields
- };
- window.idpcStart();
-});
-';
-
-$secureRenderer->renderTag('script', [], $script, false);
+?>
+
+
+renderTag('script', [], '
+ document.addEventListener("DOMContentLoaded", function() {
+ var apiKey = "' . $helper->getAdminConfig('api_key') . '";
+ var autocomplete = ' . $helper->getAdminConfig('addressAutocomplete') . ';
+ var removeOrganisation = ' . $helper->getAdminConfig('removeOrganisation') . ';
+ var populateCounty = ' . $helper->getAdminConfig('requireCounty') . ';
+ var enabled = ' . $helper->getAdminConfig('enabled') . ';
+ var customFields = ' . trim(preg_replace("/\r|\n/", "", $helper->getAdminConfig('customFields'))) . ';
+ // Exit early if disabled
+ if (enabled === false) return;
+ window.idpcConfig = {
+ apiKey: apiKey,
+ postcodeLookup: false,
+ autocomplete: autocomplete,
+ populateCounty: populateCounty,
+ removeOrganisation: removeOrganisation,
+ hoistCountry: false,
+ customFields: customFields
+ };
+ window.idpcStart();
+ });
+ ', false);
+}
?>
diff --git a/view/frontend/templates/store.phtml b/view/frontend/templates/store.phtml
index 94ade0ac..4d211f8f 100644
--- a/view/frontend/templates/store.phtml
+++ b/view/frontend/templates/store.phtml
@@ -1,18 +1,19 @@
helper('Idealpostcodes\Ukaddresssearch\Helper\Data');
-$script = '
-console.log("should be here");
-document.addEventListener(\'DOMContentLoaded\', function() {
- var apiKey = "' . $helper->getConfig('api_key') . '";
- var postcodeLookup = ' . $helper->getConfig('postcodeLookup') . ';
- var autocomplete = ' . $helper->getConfig('addressAutocomplete') . ';
- var removeOrganisation = ' . $helper->getConfig('removeOrganisation') . ';
- var hoistCountry = ' . $helper->getConfig('hoistCountryField') . ';
- var populateCounty = ' . $helper->getConfig('requireCounty') . ';
- var autocompleteOverride = ' . $helper->getConfig('autocompleteOverride') . ';
- var postcodeLookupOverride = ' . $helper->getConfig('postcodeLookupOverride') . ';
- var enabled = ' . $helper->getConfig('enabled') . ';
- var customFields = ' . trim(preg_replace("/\r|\n/", "", $helper->getConfig('customFields'))) . ';
+?>
+
+
+renderTag('script', [], '
+ document.addEventListener("DOMContentLoaded", function() {
+ var apiKey = "' . $helper->getConfig('api_key') . '";
+ var postcodeLookup = ' . $helper->getConfig('postcodeLookup') . ';
+ var autocomplete = ' . $helper->getConfig('addressAutocomplete') . ';
+ var removeOrganisation = ' . $helper->getConfig('removeOrganisation') . ';
+ var hoistCountry = ' . $helper->getConfig('hoistCountryField') . ';
+ var populateCounty = ' . $helper->getConfig('requireCounty') . ';
+ var autocompleteOverride = ' . $helper->getConfig('autocompleteOverride') . ';
+ var postcodeLookupOverride = ' . $helper->getConfig('postcodeLookupOverride') . ';
+ var enabled = ' . $helper->getConfig('enabled') . ';
+ var customFields = ' . trim(preg_replace('/\r|\n/', '', $helper->getConfig('customFields'))) . ';
+ // Exit early if disabled
+ if (enabled === false) return;
+ window.idpcConfig = {
+ apiKey: apiKey,
+ postcodeLookup: postcodeLookup,
+ autocomplete: autocomplete,
+ populateCounty: populateCounty,
+ removeOrganisation: removeOrganisation,
+ hoistCountry: hoistCountry,
+ autocompleteOverride: autocompleteOverride,
+ postcodeLookupOverride: postcodeLookupOverride,
+ customFields: customFields
+ };
+ window.idpcStart();
+ });
+', false);
+}
?>
-= /* @noEscape */ $secureRenderer->renderTag('script', ['type' => 'text/javascript', 'id' => 'idpc-config'], $script, false); ?>