-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 633180d
Showing
7 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Smart Address | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# smart-address-autocomplete-for-woocommerce | ||
Unit-level Australian address autocomplete for WooCommerce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
// Add a settings tab in WooCommerce. | ||
add_filter('woocommerce_settings_tabs_array', 'add_smart_address_settings_tab', 50); | ||
function add_smart_address_settings_tab($settings_tabs) | ||
{ | ||
$settings_tabs['smart_address'] = __('Smart Address', 'smart-address'); | ||
return $settings_tabs; | ||
} | ||
|
||
// Add settings to the tab. | ||
add_action('woocommerce_settings_tabs_smart_address', 'smart_address_settings'); | ||
function smart_address_settings() | ||
{ | ||
woocommerce_admin_fields(get_smart_address_settings()); | ||
} | ||
|
||
// Save the settings. | ||
add_action('woocommerce_update_options_smart_address', 'update_smart_address_settings'); | ||
function update_smart_address_settings() | ||
{ | ||
woocommerce_update_options(get_smart_address_settings()); | ||
} | ||
|
||
// Define the settings. | ||
function get_smart_address_settings() | ||
{ | ||
|
||
$settings = array( | ||
'section_title' => array( | ||
'name' => __('Smart Address Settings', 'smart-address'), | ||
'type' => 'title', | ||
'desc' => '', | ||
'id' => 'smart_address_section_title' | ||
), | ||
'api_key' => array( | ||
'name' => __('API Key', 'smart-address'), | ||
'type' => 'text', | ||
'desc' => __('Enter your API key here. <a href="https://smartaddress.au" target="_blank">Click here</a> to get one. ', 'smart-address'), | ||
'id' => 'smart_address_api_key' | ||
), | ||
'enable_extension' => array( | ||
'name' => __('Enable Plugin', 'smart-address'), | ||
'type' => 'checkbox', | ||
'desc' => __('Enable the Smart Address plugin.', 'smart-address'), | ||
'id' => 'smart_address_enable_extension' | ||
), | ||
'country_list' => array( | ||
'name' => __('Default Country', 'smart-address'), | ||
'type' => 'select', | ||
'desc' => __('Select the default country.', 'smart-address'), | ||
'id' => 'smart_address_country_list', | ||
'options' => array( | ||
'all' => __('All Countries', 'smart-address'), | ||
'au' => __('Australia', 'smart-address'), | ||
), | ||
'default' => 'au' | ||
), | ||
'section_end' => array( | ||
'type' => 'sectionend', | ||
'id' => 'smart_address_section_end' | ||
) | ||
); | ||
|
||
return $settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
add_action('wp_footer', function () { | ||
if (is_checkout()) { | ||
|
||
// Check if the plugin is enabled. | ||
if ('yes' === get_option('smart_address_enable_extension')) { | ||
|
||
// Get the API key from the options. | ||
$api_key = get_option('smart_address_api_key'); | ||
|
||
// Enqueue the remote JS file. | ||
wp_enqueue_script('smart-address-remote', 'https://smartaddress.au/smart-address-woocommerce.js?key=' . $api_key, array(), '1.0.0', true); | ||
|
||
// Pass the API nonce to the enqueued script. | ||
wp_localize_script('smart-address-remote', 'wc_store_params', [ | ||
'api_nonce' => wp_create_nonce('wc_store_api') | ||
]); | ||
|
||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
=== Smart Address for WooCommerce === | ||
Contributors: smartaddress | ||
Tags: woocommerce, address, autocomplete, checkout | ||
Requires at least: 5.0 | ||
Tested up to: 6.4.3 | ||
Requires PHP: 7.0 | ||
Stable tag: 1.0.0 | ||
License: GPLv2 or later | ||
License URI: https://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
|
||
== Description == | ||
|
||
Maximise your customers' WooCommerce checkout experience with our advanced Smart Address autocomplete plugin. Utilising the Smart Address API, this plugin delivers precise unit-level address autocomplete, ensuring every delivery reaches its destination without fail. | ||
|
||
By eliminating the risks of inaccurate addresses, your business can maintain high customer satisfaction, avoid unnecessary delivery retries, and save valuable resources like time and money. Enhance your checkout process and streamline your operations with the Smart Address autocomplete plugin, a smart investment for any delivery-focused WooCommerce store | ||
|
||
Smart Address for WooCommerce adds an intelligent address autocomplete feature to your WooCommerce checkout, powered by [Smart Address API](https://smartaddress.au). Simplify the checkout process for your customers, reduce errors, and increase conversion rates with this easy-to-use plugin. | ||
|
||
Features: | ||
|
||
* Unit-level Australian address autocomplete. | ||
* Supports both billing and shipping address fields. | ||
* Lightweight and fast, with virtually no impact on site performance. | ||
* Easy setup with a simple settings page in WooCommerce. | ||
|
||
== Installation == | ||
|
||
Installing Smart Address for WooCommerce is straightforward, just follow the steps below. | ||
|
||
1. Upload the plugin files to the `/wp-content/plugins/smart-address-autocomplete-for-woocommerce` directory, or install the plugin through the WordPress plugins screen directly. | ||
2. Activate the plugin through the 'Plugins' screen in WordPress. | ||
3. Go to WooCommerce > Settings > Smart Address to configure the plugin. | ||
4. Enter your API key and select your preferred settings. | ||
5. Save your changes and enjoy smart address autocomplete on your checkout page! | ||
|
||
*[Click here](https://smartaddress.au) if you don't have an Smart Address API key* | ||
|
||
== Frequently Asked Questions == | ||
|
||
= Does this plugin work with all address APIs? = | ||
|
||
The plugin is designed to work with [Smart Address API](https://smartaddress.au) that returns Australian unit-level address suggestions. | ||
|
||
= Can I use this plugin for both billing and shipping addresses? = | ||
|
||
Yes! Smart Address for WooCommerce supports autocomplete for both billing and shipping address fields. | ||
|
||
== Changelog == | ||
|
||
= 1.0.0 = | ||
* Initial release. | ||
|
||
== Upgrade Notice == | ||
|
||
= 1.0.0 = | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/* | ||
Plugin Name: Smart Address Autocomplete for WooCommerce | ||
Description: Unit-level Australian address autocomplete for WooCommerce. Accuracy and affordability redefined. Never miss a delivery again! | ||
Version: 1.0.0 | ||
Author: <a href="https://smartaddress.au">Smart Address</a> | ||
*/ | ||
|
||
if (!defined('ABSPATH')) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
// Check if WooCommerce is active. | ||
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { | ||
|
||
// Include the main plugin file. | ||
include_once 'includes/admin-settings.php'; | ||
|
||
// Include the public scripts file. | ||
include_once 'includes/public-scripts.php'; | ||
} | ||
|
||
// Add the plugin activation and deactivation hooks. | ||
register_activation_hook(__FILE__, 'smart_address_activate'); | ||
function smart_address_activate() | ||
{ | ||
if (!class_exists('WooCommerce')) { | ||
deactivate_plugins(plugin_basename(__FILE__)); | ||
wp_die('This plugin requires WooCommerce to be installed and active.'); | ||
} | ||
} | ||
|
||
// Add the plugin uninstall hook. | ||
register_uninstall_hook(__FILE__, 'smart_address_uninstall'); | ||
function smart_address_uninstall() | ||
{ | ||
delete_option('smart_address_api_key'); | ||
delete_option('smart_address_enable_extension'); | ||
delete_option('smart_address_country_list'); | ||
} | ||
|
||
// Add the settings link to the plugin. | ||
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'smart_address_action_links'); | ||
function smart_address_action_links($links) | ||
{ | ||
$settings_link = '<a href="' . admin_url('admin.php?page=wc-settings&tab=smart_address') . '">' . __('Settings', 'smart-address') . '</a>'; | ||
array_unshift($links, $settings_link); | ||
return $links; | ||
} |