diff --git a/assets/public/js/maps/checkout-page-map.js b/assets/public/js/maps/checkout-page-map.js index 04f6832..9d50278 100644 --- a/assets/public/js/maps/checkout-page-map.js +++ b/assets/public/js/maps/checkout-page-map.js @@ -670,7 +670,7 @@ function changeMapVisibility(show){ */ function lpacHideShowMap(){ - wp.ajax.post( "lpac_to_be_or_not_to_be", {} ) + wp.ajax.post( "lpac_checkout_map_visibility", {} ) .done(function(response) { const show = Boolean(response); @@ -866,7 +866,7 @@ addPlacesAutoComplete(); if( ! mapOptions.lpac_places_autocomplete_hide_map ){ $(document.body).on('updated_checkout', lpacHideShowMap); } - + // If the auto detect location feature is turned on, then detect the location but don't output the last order details. if( mapOptions.lpac_auto_detect_location ){ lpac_bootstrap_map_functionality(geocoder, map, infowindow) diff --git a/class-lpac-uninstall.php b/class-lpac-uninstall.php index 33ab3d5..597fd8c 100644 --- a/class-lpac-uninstall.php +++ b/class-lpac-uninstall.php @@ -95,6 +95,7 @@ public static function remove_plugin_settings() { 'lpac_map_anchor_points', 'lpac_admin_view_order_map_id', 'lpac_installed_at_version', + 'lpac_first_install_date', 'lpac_remove_address_plus_code', 'lpac_enable_places_autocomplete', 'lpac_places_autocomplete_fields', diff --git a/includes/Bootstrap/Main.php b/includes/Bootstrap/Main.php index 13d4c5a..96aa077 100644 --- a/includes/Bootstrap/Main.php +++ b/includes/Bootstrap/Main.php @@ -273,8 +273,8 @@ private function define_public_hooks() /* * Handles showing or hiding of map. Fires everytime the checkout page is updated. */ - $this->loader->add_action( 'wp_ajax_nopriv_lpac_to_be_or_not_to_be', $controller_map_visibility, 'checkout_map_visibility_ajax_handler' ); - $this->loader->add_action( 'wp_ajax_lpac_to_be_or_not_to_be', $controller_map_visibility, 'checkout_map_visibility_ajax_handler' ); + $this->loader->add_action( 'wp_ajax_nopriv_lpac_checkout_map_visibility', $controller_map_visibility, 'checkout_map_visibility_ajax_handler' ); + $this->loader->add_action( 'wp_ajax_lpac_checkout_map_visibility', $controller_map_visibility, 'checkout_map_visibility_ajax_handler' ); /* * Validate checkout map details and then add the latitude and longitude to the order meta. */ diff --git a/includes/Models/Location_Details.php b/includes/Models/Location_Details.php index a8c772a..a457669 100644 --- a/includes/Models/Location_Details.php +++ b/includes/Models/Location_Details.php @@ -36,8 +36,8 @@ public function validate_map_visibility( $order_id, $data ) { return; } - $lat = $data['lpac_latitude'] ?? ''; - $long = $data['lpac_longitude'] ?? ''; + $lat = (float) $data['lpac_latitude'] ?? (float) 0.0; + $long = (float) $data['lpac_longitude'] ?? (float) 0.0; $this->save_order_meta_cords( $order_id, $lat, $long ); diff --git a/includes/Notices/Admin.php b/includes/Notices/Admin.php index 60c0efe..de6b42e 100644 --- a/includes/Notices/Admin.php +++ b/includes/Notices/Admin.php @@ -88,4 +88,8 @@ public function output_php_version_notice() { } + public function create_pro_version_released_notice() { + // TODO Create notice helper functions with notice ID in URL and should_show_notice($user_id, $notice_id) method + } + } diff --git a/includes/class-lpac-activator.php b/includes/class-lpac-activator.php index b4941aa..57ffa6a 100644 --- a/includes/class-lpac-activator.php +++ b/includes/class-lpac-activator.php @@ -38,8 +38,16 @@ public static function activate() { * @return void */ private static function lpac_add_default_settings() { + $installed_at = get_option( 'lpac_installed_at_version' ); + $install_date = get_option( 'lpac_first_install_date' ); + + // Create date timestamp when plugin was first installed. + if ( empty( $install_date ) ) { + add_option( 'lpac_first_install_date', time(), '', 'yes' ); + } + // Create entry for plugin first install version. if ( empty( $installed_at ) ) { add_option( 'lpac_installed_at_version', LPAC_VERSION, '', false ); } diff --git a/lpac.php b/lpac.php index 8318c80..f4cb1ab 100644 --- a/lpac.php +++ b/lpac.php @@ -15,9 +15,9 @@ * * @wordpress-plugin * Plugin Name: Location Picker At Checkout For WooCommerce - * Plugin URI: https://soaringleads.com + * Plugin URI: https://lpacwp.com * Description: Allow customers to choose their shipping location using a map at checkout. - * Version: 1.4.1-lite + * Version: 1.4.2-lite * Author: Uriahs Victor * Author URI: https://uriahsvictor.com * License: GPL-2.0+ @@ -32,6 +32,35 @@ if ( !defined( 'WPINC' ) ) { die; } +if ( !defined( 'LPAC_VERSION' ) ) { + define( 'LPAC_VERSION', '1.4.2' ); +} +/** + * The code that runs during plugin activation. + * This action is documented in includes/class-lpac-activator.php + */ +if ( !function_exists( 'activate_lpac' ) ) { + function activate_lpac() + { + require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-activator.php'; + Lpac_Activator::activate(); + } + +} +/** + * The code that runs during plugin deactivation. + * This action is documented in includes/class-lpac-deactivator.php + */ +if ( !function_exists( 'deactivate_lpac' ) ) { + function deactivate_lpac() + { + require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-deactivator.php'; + Lpac_Deactivator::deactivate(); + } + +} +register_activation_hook( __FILE__, 'activate_lpac' ); +register_deactivation_hook( __FILE__, 'deactivate_lpac' ); /* * Check if the Free version is installed and show notice about deactivating it. * We're checking the plugin folder so this can only be ran for the PRO plugin. @@ -54,7 +83,7 @@ HTML element 2: Opening HTML element 3: Closing HTML element 4: Closing

HTML element */ echo sprintf( - __( '%1$s%2$sLocation Picker at Checkout for WooCommerce(LPAC) NOTICE:%3$s You need to deactivate and delete the free version of the plugin before using the PRO version. Your current settings will remain in place.%4$s', 'map-location-picker-at-checkout-for-woocommerce' ), + __( '%1$s%2$sLocation Picker at Checkout for WooCommerce(LPAC) NOTICE:%3$s You need to deactivate and DELETE the free version of the plugin before using the PRO version. Your current settings will remain in place.%4$s', 'map-location-picker-at-checkout-for-woocommerce' ), '

', '', '', @@ -150,7 +179,6 @@ function lpac_fs() * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'LPAC_VERSION', '1.4.1' ); define( 'LPAC_PLUGIN_NAME', 'lpac' ); define( 'LPAC_PLUGIN_DIR', __DIR__ . '/' ); define( 'LPAC_PLUGIN_ASSETS_DIR', __DIR__ . '/assets/' ); @@ -174,32 +202,6 @@ function lpac_fs() } } define( 'LPAC_DEBUG', $debug ); -/** - * The code that runs during plugin activation. - * This action is documented in includes/class-lpac-activator.php - */ -if ( !function_exists( 'activate_lpac' ) ) { - function activate_lpac() - { - require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-activator.php'; - Lpac_Activator::activate(); - } - -} -/** - * The code that runs during plugin deactivation. - * This action is documented in includes/class-lpac-deactivator.php - */ -if ( !function_exists( 'deactivate_lpac' ) ) { - function deactivate_lpac() - { - require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-deactivator.php'; - Lpac_Deactivator::deactivate(); - } - -} -register_activation_hook( __FILE__, 'activate_lpac' ); -register_deactivation_hook( __FILE__, 'deactivate_lpac' ); /** * Begins execution of the plugin. * diff --git a/readme.txt b/readme.txt index 9c55a3e..c79dd27 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: woocommerce, location picker, checkout map, geolocation, google map, map, Requires at least: 5.5 Requires PHP: 7.0 Tested up to: 5.8 -Stable tag: 1.4.0 +Stable tag: 1.4.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -162,6 +162,9 @@ The save location of QR codes have been changed. Links to QR codes in past order == Changelog == += 1.4.2 = +* [Fix] Checkout process would halt unless a location was selected by a customer regardless of "Force Map use" option status. + = 1.4.1 = * [New PRO] Export Order Locations. * [New PRO] Custom Google Map Designs.