Skip to content

Commit 39ad25e

Browse files
committed
1.0.8 Updated to use swiftlookup.js
1 parent bc29ec3 commit 39ad25e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

addressfinder.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function launchAddressLookup(type, key, searchFor, hideFields, biasTowards, plac
3030
if (searchFor && searchFor.indexOf('what3words') != -1)
3131
addressFields.push({ container: document.getElementById('swiftcomplete_what3words_field'), field: document.getElementById("swiftcomplete_what3words"), format: "what3words" });
3232

33-
swiftcomplete.controls[type] = new swiftcomplete.PlaceAutoComplete({
33+
swiftcomplete.controls[type] = new swiftcomplete.SwiftLookup({
3434
key,
3535
searchFor: searchFor,
3636
field: autocompleteField,
@@ -46,7 +46,7 @@ function launchAddressLookup(type, key, searchFor, hideFields, biasTowards, plac
4646

4747
swiftcomplete.controls[type].biasTowards(biasTowards);
4848

49-
autocompleteField.addEventListener('swiftcomplete:place:selected', function (e) {
49+
autocompleteField.addEventListener('swiftcomplete:swiftlookup:selected', function (e) {
5050
for (var i = 0; i < addressFields.length; i++) {
5151
addressFields[i].container.style.display = 'block';
5252

@@ -57,7 +57,7 @@ function launchAddressLookup(type, key, searchFor, hideFields, biasTowards, plac
5757
}
5858
}, false);
5959

60-
autocompleteField.addEventListener('swiftcomplete:place:manualentry', function (e) {
60+
autocompleteField.addEventListener('swiftcomplete:swiftlookup:manualentry', function (e) {
6161
for (var i = 0; i < addressFields.length; i++) {
6262
document.getElementById('swiftcomplete_' + type + '_address_autocomplete_field').style.display = 'none';
6363
addressFields[i].container.style.display = 'block';
@@ -112,7 +112,7 @@ function launchAdminAddressLookup(type, key, searchFor, hideFields, biasTowards,
112112

113113
addressFields.push({ field: document.getElementById('_' + type + '_postcode'), format: "POSTCODE" });
114114

115-
swiftcomplete.controls[type] = new swiftcomplete.PlaceAutoComplete({
115+
swiftcomplete.controls[type] = new swiftcomplete.SwiftLookup({
116116
key,
117117
searchFor: searchFor,
118118
field: autocompleteField,
@@ -194,7 +194,7 @@ function initialiseSwiftcompleteBlocks(type, key, searchFor, hideFields, biasTow
194194
if (searchFor && searchFor.indexOf('what3words') != -1)
195195
addressFields.push({ field: document.getElementById("swiftcomplete_what3words"), format: "what3words" });
196196

197-
swiftcomplete.controls[type] = new swiftcomplete.PlaceAutoComplete({
197+
swiftcomplete.controls[type] = new swiftcomplete.SwiftLookup({
198198
key,
199199
searchFor: searchFor,
200200
field: autocompleteField,
@@ -211,15 +211,15 @@ function initialiseSwiftcompleteBlocks(type, key, searchFor, hideFields, biasTow
211211

212212
swiftcomplete.controls[type].biasTowards(biasTowards);
213213

214-
autocompleteField.addEventListener('swiftcomplete:place:selected', function (e) {
214+
autocompleteField.addEventListener('swiftcomplete:swiftlookup:selected', function (e) {
215215
if (document.getElementById(type + '-postcode'))
216216
document.getElementById(type + '-postcode').dispatchEvent(new Event('input', { bubbles: true }));
217217

218218
for (var i = 0; i < addressFields.length; i++)
219219
addressFields[i].container.style.display = 'block';
220220
}, false);
221221

222-
autocompleteField.addEventListener('swiftcomplete:place:manualentry', function (e) {
222+
autocompleteField.addEventListener('swiftcomplete:swiftlookup:manualentry', function (e) {
223223
for (var i = 0; i < addressFields.length; i++) {
224224
document.getElementById('swiftcomplete_' + type + '_address_autocomplete_field').style.display = 'none';
225225
addressFields[i].container.style.display = 'block';

swiftcomplete.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function add_swiftcomplete_order_billing($fields)
440440
if ($settings !== false && array_key_exists('api_key', $settings) && strlen($settings['api_key']) > 0)
441441
$api_key = $settings['api_key'];
442442

443-
wp_enqueue_script('swiftcomplete_script', 'https://script.swiftcomplete.com/js/swiftcomplete.js');
443+
wp_enqueue_script('swiftcomplete_script', 'https://assets.swiftcomplete.com/js/swiftlookup.js');
444444
wp_enqueue_script('swiftcomplete_launch', plugin_dir_url(__FILE__) . 'addressfinder.js', array('jquery'), '1.0.7');
445445
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAdminAddressLookup("billing", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('billing_placeholder', $settings) ? esc_attr($settings['billing_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));
446446

@@ -476,7 +476,7 @@ function add_swiftcomplete_order_shipping($fields)
476476
if ($settings !== false && array_key_exists('api_key', $settings) && strlen($settings['api_key']) > 0)
477477
$api_key = $settings['api_key'];
478478

479-
wp_enqueue_script('swiftcomplete_script', 'https://script.swiftcomplete.com/js/swiftcomplete.js');
479+
wp_enqueue_script('swiftcomplete_script', 'https://assets.swiftcomplete.com/js/swiftlookup.js');
480480
wp_enqueue_script('swiftcomplete_launch', plugin_dir_url(__FILE__) . 'addressfinder.js', array('jquery'), '1.0.7');
481481
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAdminAddressLookup("shipping", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('billing_placeholder', $settings) ? esc_attr($settings['billing_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));
482482

@@ -513,7 +513,7 @@ function add_swiftcomplete_billing()
513513
if ($settings !== false && array_key_exists('api_key', $settings) && strlen($settings['api_key']) > 0)
514514
$api_key = $settings['api_key'];
515515

516-
wp_enqueue_script('swiftcomplete_script', 'https://script.swiftcomplete.com/js/swiftcomplete.js');
516+
wp_enqueue_script('swiftcomplete_script', 'https://assets.swiftcomplete.com/js/swiftlookup.js');
517517
wp_enqueue_script('swiftcomplete_launch', plugin_dir_url(__FILE__) . 'addressfinder.js', array('jquery'), '1.0.7');
518518
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAddressLookup("billing", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address,what3words' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('billing_placeholder', $settings) ? esc_attr($settings['billing_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));
519519
}
@@ -526,7 +526,7 @@ function add_swiftcomplete_shipping()
526526
if ($settings !== false && array_key_exists('api_key', $settings) && strlen($settings['api_key']) > 0)
527527
$api_key = $settings['api_key'];
528528

529-
wp_enqueue_script('swiftcomplete_script', 'https://script.swiftcomplete.com/js/swiftcomplete.js');
529+
wp_enqueue_script('swiftcomplete_script', 'https://assets.swiftcomplete.com/js/swiftlookup.js');
530530
wp_enqueue_script('swiftcomplete_launch', plugin_dir_url(__FILE__) . 'addressfinder.js', array('jquery'), '1.0.7');
531531
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAddressLookup("shipping", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address,what3words' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('shipping_placeholder', $settings) ? esc_attr($settings['shipping_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));
532532
}
@@ -539,7 +539,7 @@ function add_swiftcomplete_script()
539539
if ($settings !== false && array_key_exists('api_key', $settings) && strlen($settings['api_key']) > 0)
540540
$api_key = $settings['api_key'];
541541

542-
wp_enqueue_script('swiftcomplete_script', 'https://script.swiftcomplete.com/js/swiftcomplete.js');
542+
wp_enqueue_script('swiftcomplete_script', 'https://assets.swiftcomplete.com/js/swiftlookup.js');
543543
wp_enqueue_script('swiftcomplete_launch', plugin_dir_url(__FILE__) . 'addressfinder.js', array('jquery'), '1.0.7');
544544
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAddressLookup("shipping", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address,what3words' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('shipping_placeholder', $settings) ? esc_attr($settings['shipping_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));
545545
wp_add_inline_script('swiftcomplete_launch', sprintf('launchAddressLookup("billing", "' . esc_attr($api_key) . '", "' . ($settings === false || (!array_key_exists('w3w_enabled', $settings) || (array_key_exists('w3w_enabled', $settings) && $settings['w3w_enabled'] == true)) ? 'address,what3words' : 'address') . '", "' . ($settings !== false && array_key_exists('hide_fields', $settings) && $settings['hide_fields'] ? true : false) . '", "' . ($settings !== false && array_key_exists('bias_towards_lat_lon', $settings) ? esc_attr($settings['bias_towards_lat_lon']) : '') . '", "' . ($settings !== false && array_key_exists('billing_placeholder', $settings) ? esc_attr($settings['billing_placeholder']) : '') . '", "' . ($settings !== false && array_key_exists('state_counties_enabled', $settings) ? esc_attr($settings['state_counties_enabled']) : '') . '")'));

0 commit comments

Comments
 (0)