diff --git a/assets/admin/css/lpac-admin.css b/assets/admin/css/lpac-admin.css index c8384da..61c73f7 100644 --- a/assets/admin/css/lpac-admin.css +++ b/assets/admin/css/lpac-admin.css @@ -32,4 +32,23 @@ #lpac_export_btn{ cursor: pointer; padding: 10px; - } \ No newline at end of file + } + + hr{ + border-top: 8px solid #dcdcde !important; + } + + .titledesc.premium-subsection, .titledesc.premium-dummy-subsection{ + font-size: 18px; + } + + .premium-subsection:before{ + font-size: 20px; + margin-right: 5px; + color: gold; + } + +.premium-dummy-subsection:before{ + font-size: 20px; + margin-right: 5px; +} \ No newline at end of file diff --git a/assets/public/css/lpac-public.css b/assets/public/css/lpac-public.css index 3e827c3..960eb84 100644 --- a/assets/public/css/lpac-public.css +++ b/assets/public/css/lpac-public.css @@ -56,3 +56,10 @@ text-align: center; } + #lpac-saved-addresses ul{ + margin-left: 0; + } + + #edit-saved-addresses{ + font-size: 16px; + } diff --git a/assets/public/js/maps/base-map.js b/assets/public/js/maps/base-map.js index 6aa8a23..ccbea26 100644 --- a/assets/public/js/maps/base-map.js +++ b/assets/public/js/maps/base-map.js @@ -16,7 +16,7 @@ if (typeof lpac_pro_js !== 'undefined') { if( x_anchor.length == 0 ){ // Likely values to make the anchor appear ideal. - // The x axis anchor is usually half of the image width, the y is usally 3px over the image width + // The x axis anchor is usually half of the image width, the y is usually 3px over the image height x_anchor = marker_icon_width / 2; y_anchor = marker_icon_height + 3; } diff --git a/assets/public/js/maps/checkout-page-map.js b/assets/public/js/maps/checkout-page-map.js index 27fb731..04f6832 100644 --- a/assets/public/js/maps/checkout-page-map.js +++ b/assets/public/js/maps/checkout-page-map.js @@ -741,7 +741,7 @@ function lpacSetLastOrderMarker(){ } /** - * Places AutoComplete feature. + * Places Autocomplete feature. * * https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete * @@ -774,11 +774,20 @@ function addPlacesAutoComplete(){ } const options = { - // componentRestrictions: { country: ["us", "ca"] }, // TODO let users control this fields: ["address_components", "formatted_address", "geometry"], types: ["address"], } + /* + * Add country restrictions set in pro plugin settings + * lpac_pro_js is in global scope + */ + if( typeof (lpac_pro_js) !== 'undefined' && lpac_pro_js !== null){ + options.componentRestrictions = { + country: lpac_pro_js.places_autocomplete_restrictions + } + } + const autoComplete = new google.maps.places.Autocomplete(field, options); /* Bind the map's bounds (viewport) property to the autocomplete object, @@ -792,7 +801,7 @@ function addPlacesAutoComplete(){ const latlng = { lat: parseFloat( results[0].geometry.location.lat() ), - lng: parseFloat( results[0].geometry.location.lng() ), + lng: parseFloat( results[0].geometry.location.lng() ), } if( fieldID.includes('shipping') ){ @@ -814,7 +823,7 @@ function addPlacesAutoComplete(){ lpac_map_listen_to_clicks(); }else{ - if( mapOptions.lpac_places_fill_shipping_fields ){ + if( mapOptions.lpac_places_fill_billing_fields ){ lpac_fill_in_billing_fields(results); } @@ -822,7 +831,7 @@ function addPlacesAutoComplete(){ * When Shipping destination is set as "Force shipping to the customer billing address" in WooCommerce->Shipping->Shipping Options * We would want to adjust the map as needed. */ - if( mapOptions.lpac_wc_shipping_destination_setting === 'billing_only'){ + if( mapOptions.lpac_wc_shipping_destination_setting === 'billing_only' || ( fields.length === 1 && fields.includes('billing_address_1') ) ){ lpac_fill_in_latlng(latlng); map.setCenter(latlng); marker.setPosition(latlng); diff --git a/class-lpac-uninstall.php b/class-lpac-uninstall.php index 3101524..33ab3d5 100644 --- a/class-lpac-uninstall.php +++ b/class-lpac-uninstall.php @@ -33,6 +33,20 @@ class Lpac_Uninstall { */ public static function remove_plugin_settings() { + /** + * If the free version and PRO version exist then don't delete the settings. + * This ensures that users do not accidentally delete their settings when installing PRO plugin. + */ + if ( ! function_exists( 'get_plugins' ) ) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + + $plugins = get_plugins(); + + if ( array_key_exists( 'map-location-picker-at-checkout-for-woocommerce/lpac.php', $plugins ) && array_key_exists( 'map-location-picker-at-checkout-for-woocommerce-pro/lpac.php', $plugins ) ) { + return; + } + $should_delete_settings = get_option( 'lpac_delete_settings_on_uninstall' ); if ( $should_delete_settings !== 'yes' ) { @@ -84,9 +98,17 @@ public static function remove_plugin_settings() { 'lpac_remove_address_plus_code', 'lpac_enable_places_autocomplete', 'lpac_places_autocomplete_fields', + 'lpac_places_autocomplete_hide_map', 'lpac_auto_detect_location', 'lpac_export_date_from', 'lpac_export_date_to', + 'lpac_places_autocomplete_country_restrictions', + 'lpac_distance_matrix_api_key', + 'lpac_distance_matrix_store_origin_cords', + 'lpac_distance_matrix_cost_per_unit', + 'lpac_distance_matrix_distance_unit', + 'lpac_distance_matrix_travel_mode', + 'lpac_distance_matrix_shipping_methods', ); foreach ( $option_keys as $key ) { diff --git a/composer.lock b/composer.lock index 0e1b190..2d160fc 100644 --- a/composer.lock +++ b/composer.lock @@ -291,16 +291,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.1", + "version": "3.6.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e" + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f268ca40d54617c6e06757f83f699775c9b3ff2e", - "reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", "shasum": "" }, "require": { @@ -343,7 +343,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-10-11T04:00:11+00:00" + "time": "2021-12-12T21:44:58+00:00" }, { "name": "wp-coding-standards/wpcs", diff --git a/includes/Bootstrap/Main.php b/includes/Bootstrap/Main.php index 8a3c9bf..13d4c5a 100644 --- a/includes/Bootstrap/Main.php +++ b/includes/Bootstrap/Main.php @@ -168,8 +168,9 @@ private function define_admin_hooks() 10, 3 ); - /* Custom button created for WooCommerce settings */ - $this->loader->add_action( 'woocommerce_admin_field_button', $plugin_admin_view, 'create_customer_wc_settings_button' ); + /* Custom elements created for WooCommerce settings */ + $this->loader->add_action( 'woocommerce_admin_field_button', $plugin_admin_view, 'create_custom_wc_settings_button' ); + $this->loader->add_action( 'woocommerce_admin_field_hr', $plugin_admin_view, 'create_custom_wc_settings_hr' ); } /** diff --git a/includes/Controllers/Admin_Settings_Controller.php b/includes/Controllers/Admin_Settings_Controller.php index 0ffbb92..481ca7f 100644 --- a/includes/Controllers/Admin_Settings_Controller.php +++ b/includes/Controllers/Admin_Settings_Controller.php @@ -21,18 +21,18 @@ class Admin_Settings_Controller { /** * Sanitize the map default coordinates option before saving. * - * @param mixed $value - * @param mixed $option - * @param mixed $raw_value + * @param string $value + * @param array $option + * @param string $raw_value * @return string */ public function sanitize_default_map_coordinates( $value, $option, $raw_value ) { - // Remove letters from input - $value = preg_replace( '/[^0-9,.]/', '', $value ); + // Remove letters from input, allow dots and commas + $value = preg_replace( '/[^0-9,.-]/', '', $value ); $value = sanitize_text_field( $value ); - $value = trim( $value, ' ,' ); + $value = trim( $value, ' ,' ); // Remove spaces or commas infront and after value return $value; diff --git a/includes/Controllers/Emails_Controller.php b/includes/Controllers/Emails_Controller.php index 16b213b..663c950 100644 --- a/includes/Controllers/Emails_Controller.php +++ b/includes/Controllers/Emails_Controller.php @@ -14,7 +14,8 @@ namespace Lpac\Controllers; use Lpac\Helpers\Functions as Functions_Helper; -use Lpac\Helpers\QR_Code_Generator as QR_Code_Generator; +use Lpac\Helpers\QR_Code_Generator; +use Lpac\Traits\Upload_Folders; /** * Class emails. @@ -23,6 +24,7 @@ * */ class Emails_Controller { + use Upload_Folders; /** * Outputs a Button or QR Code inside order emails. @@ -40,7 +42,13 @@ public function add_delivery_location_link_to_email( $order, $sent_to_admin, $pl $latitude = get_post_meta( $order->get_id(), '_lpac_latitude', true ); $longitude = get_post_meta( $order->get_id(), '_lpac_longitude', true ); - $map_link = apply_filters( 'lpac_email_map_link_provider', "https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}", $latitude, $longitude ); + + // If we have no results return. + if ( empty( $latitude ) or empty( $longitude ) ) { + return; + } + + $map_link = apply_filters( 'lpac_email_map_link_provider', "https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}", $latitude, $longitude ); $map_link_type = get_option( 'lpac_email_delivery_map_link_type' ); @@ -49,7 +57,7 @@ public function add_delivery_location_link_to_email( $order, $sent_to_admin, $pl } elseif ( $map_link_type === 'qr_code' ) { $this->create_delivery_location_link_qrcode( $map_link, $order->get_id() ); } elseif ( $map_link_type === 'static_map' ) { - $this->create_delivery_location_static_map( $map_link, $latitude, $longitude ); + $this->create_delivery_location_static_map( $order->get_id(), $map_link, $latitude, $longitude ); } else { $this->create_delivery_location_link_button( $map_link ); } @@ -88,6 +96,9 @@ private function create_delivery_location_link_button( $link ) { */ private function create_delivery_location_link_qrcode( $link, $order_id ) { + $folder_name = 'qr-codes'; + + // TODO allow controlling of these figures $options = array( 'qr_code_data' => $link, 'qr_code_foreground_rgb' => '0,0,0', @@ -97,17 +108,17 @@ private function create_delivery_location_link_qrcode( $link, $order_id ) { /* * Generate and save QR Code */ - QR_Code_Generator::lpac_generate_qr_code( $options, $order_id ); + ( new QR_Code_Generator )->lpac_generate_qr_code( $options, $order_id ); /* - * https://example.com/wp-content/uploads/lpac/qr-codes/Y/m/d/order_id.jpg + * https://example.com/wp-content/uploads/lpac/qr-codes/order_id.jpg */ - $qr_code_link = Functions_Helper::lpac_get_qr_codes_directory( 'baseurl' ) . $order_id . '.jpg'; + $qr_code_link = $this->get_resource_url( $folder_name, $order_id, '.jpg' ); $delivery_location_text = __( 'Delivery Location', 'map-location-picker-at-checkout-for-woocommerce' ); $delivery_location_text = apply_filters( 'lpac_email_map_location_link_button_text', $delivery_location_text ); echo "
- +

{$delivery_location_text}

"; @@ -121,7 +132,9 @@ private function create_delivery_location_link_qrcode( $link, $order_id ) { * @return void * @since 1.4.0 */ - private function create_delivery_location_static_map( $map_link, $latitude, $longitude ) { + private function create_delivery_location_static_map( $order_id, $map_link, $latitude, $longitude ) { + + $folder_name = 'static-maps'; $center = $latitude . ',' . $longitude; $center = sanitize_text_field( apply_filters( 'lpac_email_static_map_center', $center ) ); @@ -143,6 +156,18 @@ private function create_delivery_location_static_map( $map_link, $latitude, $lon $api_key ); + $save_path = $this->create_upload_folder( $folder_name ); + + $file_name = $save_path . $order_id . '.jpg'; + + $image = file_put_contents( $file_name, file_get_contents( $full_link ) ); + + if ( empty( $image ) ) { + return; + } + + $image_src = $this->get_resource_url( $folder_name, $order_id, '.jpg' ); + $width = ''; $height = ''; @@ -152,7 +177,7 @@ private function create_delivery_location_static_map( $map_link, $latitude, $lon $height = $size_parts[1]; } - $image = ""; + $image = ""; echo $image; } diff --git a/includes/Helpers/QR_Code_Generator.php b/includes/Helpers/QR_Code_Generator.php index 7ef4b7b..27633a3 100644 --- a/includes/Helpers/QR_Code_Generator.php +++ b/includes/Helpers/QR_Code_Generator.php @@ -21,10 +21,13 @@ use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin; use Endroid\QrCode\Writer\PngWriter; use Endroid\QrCode\Label\Font\NotoSans; +use Lpac\Traits\Upload_Folders; // use Endroid\QrCode\Label\Font\OpenSans; class QR_Code_Generator { + use Upload_Folders; + /** * Creates a QR code * @@ -33,9 +36,11 @@ class QR_Code_Generator { * * @since 1.1.0 */ - public static function lpac_generate_qr_code( $options, $order_id ) { + public function lpac_generate_qr_code( $options, $order_id ) { + + $folder_name = 'qr-codes'; - $path = self::lpac_qr_codes_directory(); + $path = $this->create_upload_folder( $folder_name ); if ( empty( $path ) ) { error_log( 'Location Picker At Checkout for WooCommerce: QR Code directory path returned empty. See Lpac_Qr_Code_Generator::lpac_generate_qr_code()' ); @@ -91,30 +96,4 @@ public static function lpac_generate_qr_code( $options, $order_id ) { } - /** - * Creates a QR code - * - * @since 1.1.0 - */ - public static function lpac_qr_codes_directory() { - - $upload_dir = wp_upload_dir(); - $qr_codes_dir = ''; - - if ( ! empty( $upload_dir['basedir'] ) ) { - - $qr_codes_dir = $upload_dir['basedir'] . '/lpac/qr-codes/' . date( 'Y' ) . '/' . date( 'm' ) . '/' . date( 'd' ) . '/'; - $qr_codes_dir = apply_filters( 'lpac_qrcodes_path', $qr_codes_dir ); - - if ( ! file_exists( $qr_codes_dir ) ) { - wp_mkdir_p( $qr_codes_dir ); - } - - return $qr_codes_dir; - } - - return $qr_codes_dir; - - } - } diff --git a/includes/Notices/Admin.php b/includes/Notices/Admin.php index 212a4c6..60c0efe 100644 --- a/includes/Notices/Admin.php +++ b/includes/Notices/Admin.php @@ -28,7 +28,10 @@ public function lpac_wc_not_active_notice() { ?>
- ', '', '', '

' ); ?> + 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 WooCommerce is not activated, please activate it to use the plugin.%4$s', 'map-location-picker-at-checkout-for-woocommerce' ), '

', '', '', '

' ); + ?>
-
- ', '', '', '

' ); ?> -
- + 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 HTTPS not detected on this website. The plugin will not work. Please enable HTTPS on this website.%4$s', 'map-location-picker-at-checkout-for-woocommerce' ), '

', '', '', '

' ); + ?> + +
- ', '', '', '

' ); ?> + 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 PHP version too low to use this plugin. Please change to at least PHP 7.0. You can contact your web host for assistance in updating your PHP version.%4$s', 'map-location-picker-at-checkout-for-woocommerce' ), '

', '', '', '

' ); + ?>
$name - + +

$description

+ + +HTML; + echo $markup; + + } + + /** + * Create a custom hr element that can be used on the plugin's settings page. + * + * @param array $value + * @return void + */ + public function create_custom_wc_settings_hr( $value ) { + + $class = $value['class']; + $name = $value['name']; + $description = $value['desc']; + + $markup = << + $name + +

$description

diff --git a/includes/Views/Admin_Settings.php b/includes/Views/Admin_Settings.php index 2258244..016be65 100644 --- a/includes/Views/Admin_Settings.php +++ b/includes/Views/Admin_Settings.php @@ -64,11 +64,10 @@ public function lpac_create_plugin_settings_sections() 'general' => __( 'General', 'map-location-picker-at-checkout-for-woocommerce' ), 'display' => __( 'Display', 'map-location-picker-at-checkout-for-woocommerce' ), 'visibility_rules' => __( 'Visibility Rules', 'map-location-picker-at-checkout-for-woocommerce' ), - 'export' => '', - 'premium' => __( 'Premium', 'map-location-picker-at-checkout-for-woocommerce' ), + 'export' => __( 'Export', 'map-location-picker-at-checkout-for-woocommerce' ), + 'pro' => __( 'More Features', 'map-location-picker-at-checkout-for-woocommerce' ), 'debug' => __( 'Debug', 'map-location-picker-at-checkout-for-woocommerce' ), ); - unset( $sections['export'] ); return apply_filters( 'woocommerce_get_sections_' . LPAC_PLUGIN_NAME, $sections ); } @@ -105,7 +104,7 @@ public function lpac_create_plugin_settings_banner() if ( empty(get_option( 'lpac_google_maps_api_key', '' )) ) { $no_api_key = __( 'You need an API Key to use Google Maps. Please see this document for how to get it ', 'map-location-picker-at-checkout-for-woocommerce' ); - $no_api_key .= "{$here}"; + $no_api_key .= "{$here}"; $no_api_key .= $external_icon; } else { $no_api_key = ''; @@ -116,7 +115,7 @@ public function lpac_create_plugin_settings_banner() $issues .= "{$here}"; $issues .= $external_icon; $documentation = __( 'Read the documentation ', 'map-location-picker-at-checkout-for-woocommerce' ); - $documentation .= "{$here}"; + $documentation .= "{$here}"; $documentation .= $external_icon; $translate_plugin = __( 'Plugin settings not in your Language? Help translate it ', 'map-location-picker-at-checkout-for-woocommerce' ); $translate_plugin .= "{$here}"; @@ -177,17 +176,18 @@ public function lpac_create_general_setting_fields() } $lpac_settings[] = array( - 'name' => __( 'Google Maps API Key', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => __( 'Enter the API key from Google cloud console.', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc' => __( 'Enter the API key you copied from the Google Cloud Console. Learn More ', 'map-location-picker-at-checkout-for-woocommerce' ), - 'id' => 'lpac_google_maps_api_key', - 'type' => 'text', - 'css' => 'min-width:300px;', + 'name' => __( 'Google Maps API Key', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'Enter the API key from Google cloud console.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Enter the API key you copied from the Google Cloud Console. Learn More ', 'map-location-picker-at-checkout-for-woocommerce' ), + 'id' => 'lpac_google_maps_api_key', + 'placeholder' => 'AIzaSyD8seU-lym435g...', + 'type' => 'password', + 'css' => 'min-width:300px;', ); $lpac_settings[] = array( 'name' => __( 'Detect Customer Location on Checkout Page Load', 'map-location-picker-at-checkout-for-woocommerce' ), 'desc' => __( 'Yes', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'Enabling this option will have the plugin immediately try to detect the customer location when the checkout page loads. NOTE: This can negatively impact customer experiences. Think carefully before enabling this option. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'desc_tip' => sprintf( __( 'Enabling this option will have the plugin immediately try to detect the customer location when the checkout page loads. NOTE: This can negatively impact customer experiences. Think carefully before enabling this option. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), 'id' => 'lpac_auto_detect_location', 'type' => 'checkbox', 'css' => 'max-width:80px;', @@ -203,7 +203,7 @@ public function lpac_create_general_setting_fields() $lpac_settings[] = array( 'name' => __( 'Default Coordinates', 'map-location-picker-at-checkout-for-woocommerce' ), 'desc_tip' => __( 'Enter the default latitude and longitude that will be fetched every time the map loads.', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc' => __( 'Enter the default latitude and longitude that will be fetched every time the map loads. You can find the coordinates for a location here >>. Be sure to include the comma when adding your coordinates above.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => sprintf( __( 'Enter the default latitude and longitude that will be fetched every time the map loads. You can find the coordinates for a location %1$sHere >>%2$s. Be sure to include the comma when adding your coordinates above.', 'map-location-picker-at-checkout-for-woocommerce' ), '', '' ), 'id' => 'lpac_map_starting_coordinates', 'placeholder' => '14.024519,-60.974876', 'type' => 'text', @@ -229,7 +229,7 @@ public function lpac_create_general_setting_fields() ); $lpac_settings[] = array( 'name' => __( 'Remove Plus Code From Address', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'If you enable this option the plugin will attempt to remove the Plus Code that shows infront addresses returned by Google Maps. Example TMWXH+CW. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'desc_tip' => sprintf( __( 'If you enable this option the plugin will attempt to remove the Plus Code that shows infront addresses returned by Google Maps. Example TMWXH+CW. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), 'desc' => __( 'Yes', 'map-location-picker-at-checkout-for-woocommerce' ), 'id' => 'lpac_remove_address_plus_code', 'type' => 'checkbox', @@ -245,7 +245,7 @@ public function lpac_create_general_setting_fields() ); $lpac_settings[] = array( 'name' => __( 'Show Map on the Order Received Page', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'This option displays a map view on the order received page after an order has been placed by a customer. %s', 'map-location-picker-at-checkout-for-woocommerce' ), " {$learn_more} " ), + 'desc_tip' => sprintf( __( 'This option displays a map view on the order received page after an order has been placed by a customer. %s', 'map-location-picker-at-checkout-for-woocommerce' ), " {$learn_more} " ), 'id' => 'lpac_display_map_on_order_received_page', 'type' => 'checkbox', 'css' => 'min-width:300px;', @@ -253,7 +253,7 @@ public function lpac_create_general_setting_fields() ); $lpac_settings[] = array( 'name' => __( 'Show Map on View Order Page', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'This option displays a map view on the order details page in the customer account. %s', 'map-location-picker-at-checkout-for-woocommerce' ), " {$learn_more} " ), + 'desc_tip' => sprintf( __( 'This option displays a map view on the order details page in the customer account. %s', 'map-location-picker-at-checkout-for-woocommerce' ), " {$learn_more} " ), 'id' => 'lpac_display_map_on_view_order_page', 'type' => 'checkbox', 'css' => 'min-width:300px;', @@ -261,7 +261,7 @@ public function lpac_create_general_setting_fields() ); $lpac_settings[] = array( 'name' => __( 'Add Map Link to Order Emails?', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'Add either a Button or QR Code that links to Google Maps to the order emails. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'desc_tip' => sprintf( __( 'Add either a Button or QR Code that links to Google Maps to the order emails. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), 'id' => 'lpac_enable_delivery_map_link_in_email', 'desc' => __( 'Yes', 'map-location-picker-at-checkout-for-woocommerce' ), 'type' => 'checkbox', @@ -269,7 +269,7 @@ public function lpac_create_general_setting_fields() $lpac_settings[] = array( 'name' => __( 'Link Type', 'map-location-picker-at-checkout-for-woocommerce' ), 'desc_tip' => __( 'Add either a button to Google Maps, a QR Code or Static Map to the order emails.', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc' => sprintf( __( 'The Static Map option requires enabling a special Google Maps API. Please read the following doc to %1$s %2$s QR Codes are saved to your uploads directory at: /wp-content/uploads/lpac/qr-codes/year/month/day/order_id.jpg', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}", '
' ), + 'desc' => sprintf( __( 'The Static Map option requires enabling a special Google Maps API. Please read the following doc to %1$s %2$s QR Codes are saved to your uploads directory at: /wp-content/uploads/lpac/qr-codes/order_id.jpg', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}", '
' ), 'id' => 'lpac_email_delivery_map_link_type', 'type' => 'select', 'options' => array( @@ -307,14 +307,14 @@ public function lpac_create_general_setting_fields() ); $lpac_settings[] = array( 'name' => __( 'Enable Places Autocomplete Feature', 'map-location-picker-at-checkout-for-woocommerce' ), - 'desc_tip' => sprintf( __( 'Allows customers to begin typing an address and receive suggestions from Google. NOTE: This is not as reliable as allowing customers to select their location on the map. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'desc_tip' => sprintf( __( 'Allows customers to begin typing an address and receive suggestions from Google. NOTE: This is not as reliable as allowing customers to select their location on the map. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), 'desc' => __( 'Yes', 'map-location-picker-at-checkout-for-woocommerce' ), 'id' => 'lpac_enable_places_autocomplete', 'type' => 'checkbox', 'css' => 'min-width:300px;', ); $lpac_settings[] = array( - 'name' => __( 'Allowed Places AutoComplete Fields', 'map-location-picker-at-checkout-for-woocommerce' ), + 'name' => __( 'Allowed Places Autocomplete Fields', 'map-location-picker-at-checkout-for-woocommerce' ), 'desc' => __( 'Select the input fields where the places autocomplete should be allowed.', 'map-location-picker-at-checkout-for-woocommerce' ), 'id' => 'lpac_places_autocomplete_fields', 'type' => 'multiselect', @@ -450,6 +450,8 @@ private function lpac_create_display_setting_fields() */ private function create_visibility_settings_fields() { + /* translators: 1: Dashicons outbound link icon */ + $learn_more = sprintf( __( 'Learn More %s', 'map-location-picker-at-checkout-for-woocommerce' ), '' ); $lpac_settings = array(); $lpac_settings[] = array( 'name' => __( 'LPAC Map Visibility Rules', 'map-location-picker-at-checkout-for-woocommerce' ), @@ -468,7 +470,7 @@ private function create_visibility_settings_fields() $lpac_settings[] = array( 'name' => __( 'Hide Map for Shipping Methods', 'map-location-picker-at-checkout-for-woocommerce' ), 'class' => 'wc-enhanced-select', - 'desc' => __( 'Hide the map when any of these shipping methods are chosen by the user.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => sprintf( __( 'Hide the map when any of these shipping methods are chosen by the user. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), 'id' => 'lpac_wc_shipping_methods', 'type' => 'multiselect', 'options' => Functions_Helper::lpac_get_available_shipping_methods(), @@ -508,9 +510,341 @@ private function create_visibility_settings_fields() 'options' => Functions_Helper::get_available_coupons(), 'css' => 'min-width:300px;height: 100px', ); + if ( lpac_fs()->is_not_paying() ) { + $lpac_settings = $this->create_dummy_visibility_rules_settings_fields( $lpac_settings ); + } + $lpac_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_map_visibility_settings_section_end', + ); return $lpac_settings; } + /** + * Create Dummy Visibility Rules Pro fields. + * @param array $lpac_visibility_settings An array of Live fields to merge the dummy ones into. + * @return array + */ + private function create_dummy_visibility_rules_settings_fields( array $lpac_visibility_settings ) + { + /* translators: 1: Dashicons outbound link icon */ + $learn_more = sprintf( __( 'Learn More %s', 'map-location-picker-at-checkout-for-woocommerce' ), '' ); + $lpac_dummy_visibility_pro_settings = array(); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => 'Available in PRO', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'type' => 'hr', + 'desc' => sprintf( __( 'The Shipping Zones, Minimum Cart Subtotal and Maximum Cart Subtotal features are available in the PRO version. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + ); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => __( 'Shipping Zones', 'map-location-picker-at-checkout-for-woocommerce' ), + 'class' => 'wc-enhanced-select', + 'desc' => sprintf( __( 'Select the Shipping Zones. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'type' => 'multiselect', + 'options' => array(), + 'css' => 'height:40px', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => __( 'Show or Hide', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => sprintf( + /* translators: 1: Line break HTML 2: opening strong tag 3: closing strong tag*/ + __( 'Should the map be shown or hidden if the order falls within above selected shipping zones? %1$s%1$s Selecting %2$sShow%3$s will display the map %2$sONLY IF%3$s the customer order falls inside the shipping zones selected above. %1$s Selecting %2$sHide%3$s will display the map only if the customer order %2$sDOES NOT%3$s fall inside the shipping zones selected above.', 'map-location-picker-at-checkout-for-woocommerce' ), + '
', + '', + '' + ), + 'type' => 'radio', + 'options' => array( + 'show' => __( 'Show', 'map-location-picker-at-checkout-for-woocommerce' ), + 'hide' => __( 'Hide', 'map-location-picker-at-checkout-for-woocommerce' ), + ), + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => __( 'Minimum Cart Subtotal', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'The minimum amount the cart total should be before showing the checkout page map. NOTE: Coupons and Shipping Cost are not taken into account when calculating the cart subtotal.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'text', + 'css' => 'max-width:80px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => __( 'Maximum Cart Subtotal', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'The maximum amount the cart total can be before hiding the checkout page map. NOTE: Coupons and Shipping Cost are not taken into account when calculating the cart subtotal.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'text', + 'css' => 'max-width:80px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_visibility_pro_settings[] = array( + 'name' => '', + 'type' => 'hr', + ); + return array_merge( $lpac_visibility_settings, $lpac_dummy_visibility_pro_settings ); + } + + /** + * Create Dummy Export Pro fields. + * + * @return array + */ + private function create_dummy_export_settings_fields() + { + /* translators: 1: Dashicons outbound link icon */ + $learn_more = sprintf( __( 'Learn More %s', 'map-location-picker-at-checkout-for-woocommerce' ), '' ); + $lpac_dummy_export_pro_settings = array(); + $lpac_dummy_export_pro_settings[] = array( + 'name' => __( 'LPAC Export Order Locations', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'title', + 'desc' => $this->lpac_create_plugin_settings_banner(), + ); + $lpac_dummy_export_pro_settings[] = array( + 'name' => 'Available in PRO', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'type' => 'hr', + 'desc' => sprintf( __( 'The following features are available in the PRO version. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + ); + $lpac_dummy_export_pro_settings[] = array( + 'name' => __( 'Date From', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'date', + 'desc' => __( 'Set START date from which you want to start exporting orders.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_export_pro_settings[] = array( + 'name' => __( 'Date To', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'date', + 'desc' => __( 'Set END date from which you want to start exporting orders.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_export_pro_settings[] = array( + 'name' => __( 'Export to CSV', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'button', + 'value' => 'Download', + 'desc' => sprintf( + __( 'A .CSV file with Order ID, Customer Name, Order Date, Map Link and Phone Number will be downloaded.%1$s Files are saved to: %2$s %3$s %4$s', 'map-location-picker-at-checkout-for-woocommerce' ), + '
', + '', + '/wp-content/uploads/lpac/order-exports/', + '' + ), + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_export_pro_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_export_section_end', + ); + return $lpac_dummy_export_pro_settings; + } + + /** + * Create Dummy Pro fields. + * + * @return array + */ + private function create_dummy_pro_fields() + { + $lpac_dummy_pro_settings = array(); + /* translators: 1: Dashicons outbound link icon */ + $learn_more = sprintf( __( 'Learn More %s', 'map-location-picker-at-checkout-for-woocommerce' ), '' ); + //TODO Create tutorial for using snazzy maps + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Get More With PRO', 'map-location-picker-at-checkout-for-woocommerce' ), + 'id' => 'lpac_premium', + 'type' => 'title', + ); + $lpac_dummy_pro_settings[] = array( + 'name' => 'Map ID', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'type' => 'hr', + 'desc' => sprintf( __( 'Set the Map ID for the respective Maps. You can create a custom map for each entry. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Checkout Page Map ID', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'The Map ID to use for your Checkout page for styling.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => 'cfceab16...', + 'type' => 'text', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Order Received Page Map ID', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'The Map ID to use for your "Order Received" page for styling.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => 'cfceab16...', + 'type' => 'text', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'View Order Page Map ID', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'The Map ID to use for your "View Order" page for styling.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => 'cfceab16...', + 'type' => 'text', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Admin Dashboard View Order Page Map ID', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'The Map ID to use for your the "View Order" page inside the WordPress admin Dashboard.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => 'cfceab16...', + 'type' => 'text', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => 'Marker Icon', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'desc' => sprintf( __( 'Set a custom icon to be used for the map marker. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'type' => 'hr', + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Link to Icon', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'The icon to use as the map marker.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Enter the URL to the icon that should be used as the custom map marker.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'url', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Marker Anchor Points', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'The anchor point for the marker in X,Y values. Used to show customer where exactly they\'re moving the marker to. The X value is usually half of the image width, the Y is usually the height of the image + 3. Be sure to test the map marker after setting these values to ensure the anchor works well.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => '15, 33', + 'type' => 'text', + 'css' => 'max-width:80px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => 'Saved Addresses', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'desc' => sprintf( __( 'Allow customers to save different addresses for later use. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'type' => 'hr', + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Enable', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Yes', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'checkbox', + 'css' => 'max-width:80px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => 'Places Autocomplete', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'desc' => sprintf( __( 'Restrict the Places Autocomplete feature to your preferred country. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'type' => 'hr', + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Restrict Places Autocomplete Countries', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( "Select the countries you'd like addresses to be pulled from when using the Places Autocomplete feature.", 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc_tip' => __( 'Use this feature if you only want to show address results from a specific country or countries.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'multiselect', + 'options' => array(), + 'css' => 'height:40px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => 'Shipping Cost by Distance', + 'class' => 'dashicons-before dashicons-lock premium-dummy-subsection', + 'desc' => sprintf( __( 'Charge customers based on the distance between your store and their location. Be sure to test this before committing to the changes. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ), + 'type' => 'hr', + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Distance Matrix API Key', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'This is a specific API key created just for usage of Google\'s Distance Matrix API. The key should have no referrer restrictions set on it.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => 'AIzaSyD8seU-lym435g...', + 'type' => 'password', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Origin Coordinates', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => sprintf( __( 'Enter the coordinates of the location from which the delivery/pickup will begin. This might be the coordinates for your physical store or business. If you have multiple origin locations (example multiple stores) then enter the coordinates for the preferred one. You can find the coordinates for a location %1$sHere >>%2$s', 'map-location-picker-at-checkout-for-woocommerce' ), '', '' ), + 'placeholder' => '14.024519,-60.974876', + 'type' => 'text', + 'css' => 'max-width:180px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Cost per Unit', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Enter the price you wish to charge per Kilometer/Mile. The default store currency will be used.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => '0.50', + 'type' => 'text', + 'css' => 'max-width:80px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Distance Unit', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Select your preferred unit. By Default the Distance Matrix API returns values in Metric Units. If Miles is selected then Kilometers will be converted into Miles where 1 Kilometer is equivalent to 0.621371 Miles.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'select', + 'options' => array( + 'km' => __( 'Kilometers', 'map-location-picker-at-checkout-for-woocommerce' ), + 'mile' => __( 'Miles', 'map-location-picker-at-checkout-for-woocommerce' ), + ), + 'css' => 'max-width:120px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Travel Mode', 'map-location-picker-at-checkout-for-woocommerce' ), + 'desc' => __( 'Enter the travel mode you will be using. Though multiple options are provided, you might always want to use "driving" for best results.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'placeholder' => '2.50', + 'type' => 'select', + 'options' => array( + 'driving' => __( 'Driving', 'map-location-picker-at-checkout-for-woocommerce' ), + 'bicycling' => __( 'Bicycling', 'map-location-picker-at-checkout-for-woocommerce' ), + 'walking' => __( 'Walking', 'map-location-picker-at-checkout-for-woocommerce' ), + ), + 'css' => 'max-width:120px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'name' => __( 'Shipping Methods', 'map-location-picker-at-checkout-for-woocommerce' ), + 'class' => 'wc-enhanced-select', + 'desc' => __( 'Select the Shipping Method(s) this feature applies to. If there is a cost already set on the shipping method, then that base cost will be added to the cost calculated using the distance.', 'map-location-picker-at-checkout-for-woocommerce' ), + 'type' => 'multiselect', + 'options' => array(), + 'css' => 'height:40px;', + 'custom_attributes' => array( + 'disabled' => 'disabled', + ), + ); + $lpac_dummy_pro_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_dummy_premium_settings_section_end', + ); + return $lpac_dummy_pro_settings; + } + /** * House all the plugin settings to do with Debugging. * @@ -576,7 +910,7 @@ private function output_map_visibility_rules_order() } /* translators: 1: Learn more link*/ - $info_text = sprintf( esc_html( 'Use the table below to arrange the map visibility rules by dragging and dropping. The last rule in the the table decides the final visibility state of the map. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ); + $info_text = sprintf( esc_html( 'Use the table below to arrange the map visibility rules by dragging and dropping. The last rule in the the table decides the final visibility state of the map. %s', 'map-location-picker-at-checkout-for-woocommerce' ), "{$learn_more}" ); ?>
@@ -648,36 +982,28 @@ public function lpac_create_plugin_settings_fields() if ( $current_section === 'display' ) { $lpac_settings = $this->lpac_create_display_setting_fields(); } - if ( $current_section === 'visibility_rules' ) { $lpac_settings = $this->create_visibility_settings_fields(); - // Add section end lastly - $lpac_settings = array_merge( $lpac_settings, array( - 'type' => 'sectionend', - 'id' => 'lpac_map_visibility_settings_section_end', - ) ); } - - if ( $current_section === 'premium' ) { - // TODO Add premium purchase link - // if ( lpac_fs()->is_not_paying() ) { - // echo '

' . __('Awesome Professional Features', 'lpac') . '

'; - // echo '' . __('Upgrade Now!', 'lpac') . ''; - // echo '
'; - // } + // Add fields to Export tab + if ( lpac_fs()->is_not_paying() && $current_section === 'export' ) { + $lpac_settings = array_merge( $lpac_settings, $this->create_dummy_export_settings_fields() ); + } + if ( $current_section === 'pro' ) { if ( lpac_fs()->is_not_paying() ) { /* translators: 1: HTML break element */ - $signup_text = sprintf( __( 'Custom Maps, Custom Marker Icons, Saved Addresses, More Visibility Rules, Shipping Cost by Distance, Export Order Locations and more. %s Sign up to the waiting list for 10%% off at launch.', 'map-location-picker-at-checkout-for-woocommerce' ), '

' ); + $signup_text = sprintf( __( 'Custom Maps, Custom Marker Icons, Saved Addresses, More Visibility Rules, Shipping Cost by Distance, Export Order Locations and more. %s Get the most out of LPAC with the PRO version.', 'map-location-picker-at-checkout-for-woocommerce' ), '

' ); $learn_more = sprintf( __( 'Learn More %s', 'map-location-picker-at-checkout-for-woocommerce' ), '' ); $markup = << \t\t\t\t\t

{$signup_text}

\t\t\t\t\t
-\t\t\t\t\t

{$learn_more}

+\t\t\t\t\t

{$learn_more}

\t\t\t\t
HTML; echo $markup ; + $lpac_settings = array_merge( $lpac_settings, $this->create_dummy_pro_fields() ); } } diff --git a/includes/Views/Frontend.php b/includes/Views/Frontend.php index 277b995..f14f918 100644 --- a/includes/Views/Frontend.php +++ b/includes/Views/Frontend.php @@ -68,6 +68,12 @@ public function lpac_output_map_on_checkout_page() { $saved_addresses_area = apply_filters( 'lpac_saved_addresses', '', $user_id ); $saved_addresses_area = wp_kses_post( $saved_addresses_area ); + $edit_saved_addresses = ''; + + if ( ! empty( $saved_addresses_area ) ) { + $account_link = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) . 'edit-address/'; + $edit_saved_addresses = sprintf( esc_html__( '%1$sEdit Saved Addresses%2$s', 'map-location-picker-at-checkout-for-woocommerce' ), "", '' ); + } $before_map_filter = apply_filters( 'lpac_before_map', '', $user_id ); $before_map_filter = wp_kses_post( $before_map_filter ); @@ -91,7 +97,12 @@ public function lpac_output_map_on_checkout_page() { $before_map_controls_filter
$instuctions_text
-
    $saved_addresses_area
+
+
    + $saved_addresses_area +
+

$edit_saved_addresses

+
$after_map_controls_filter @@ -283,6 +294,10 @@ public function lpac_output_map_custom_styles() { } + if ( empty( $style ) ) { + return; + } + $output = << .lpac-map{ diff --git a/lpac.php b/lpac.php index 757b375..8318c80 100644 --- a/lpac.php +++ b/lpac.php @@ -17,7 +17,7 @@ * Plugin Name: Location Picker At Checkout For WooCommerce * Plugin URI: https://soaringleads.com * Description: Allow customers to choose their shipping location using a map at checkout. - * Version: 1.4.0 + * Version: 1.4.1-lite * Author: Uriahs Victor * Author URI: https://uriahsvictor.com * License: GPL-2.0+ @@ -32,6 +32,45 @@ if ( !defined( 'WPINC' ) ) { die; } +/* +* 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. +*/ +$plugin_folder = basename( dirname( __FILE__ ) ); + +if ( $plugin_folder === 'map-location-picker-at-checkout-for-woocommerce-pro' ) { + /** + * Deactivate free version if active. + */ + if ( !function_exists( 'get_plugins' ) || !function_exists( 'deactivate_plugins' ) ) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + $plugins = get_plugins(); + + if ( array_key_exists( 'map-location-picker-at-checkout-for-woocommerce/lpac.php', $plugins ) && array_key_exists( 'map-location-picker-at-checkout-for-woocommerce-pro/lpac.php', $plugins ) ) { + add_action( 'admin_notices', function () { + ?> +
+ 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' ), + '

', + '', + '', + '

' + ) ; + ?> +
+ 'plugin', 'public_key' => 'pk_da07de47a2bdd9391af9020cc646d', 'is_premium' => false, - 'premium_suffix' => 'Pro', + 'premium_suffix' => 'PRO', 'has_addons' => false, 'has_paid_plans' => true, 'menu' => array( - 'first-path' => 'plugins.php', + 'first-path' => 'admin.php?page=wc-settings&tab=lpac_settings', ), 'is_live' => true, ) ); @@ -69,9 +108,12 @@ function lpac_fs() } include __DIR__ . '/class-lpac-uninstall.php'; + if ( function_exists( 'lpac_fs' ) ) { lpac_fs()->add_action( 'after_uninstall', array( new Lpac_Uninstall(), 'remove_plugin_settings' ) ); + lpac_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' ); } + /** * Check that WooCommerce is active. */ @@ -108,7 +150,7 @@ 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.0' ); +define( 'LPAC_VERSION', '1.4.1' ); define( 'LPAC_PLUGIN_NAME', 'lpac' ); define( 'LPAC_PLUGIN_DIR', __DIR__ . '/' ); define( 'LPAC_PLUGIN_ASSETS_DIR', __DIR__ . '/assets/' ); @@ -136,22 +178,26 @@ function lpac_fs() * The code that runs during plugin activation. * This action is documented in includes/class-lpac-activator.php */ -function activate_lpac() -{ - require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-activator.php'; - Lpac_Activator::activate(); -} +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 */ -function deactivate_lpac() -{ - require_once plugin_dir_path( __FILE__ ) . 'includes/class-lpac-deactivator.php'; - Lpac_Deactivator::deactivate(); -} +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' ); /** diff --git a/readme.txt b/readme.txt index fbe4ccd..9c55a3e 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.3.5 +Stable tag: 1.4.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -72,6 +72,16 @@ Though the primary focus of the plugin is to allow customers to select accurate - Option to turn on Places Autocomplete feature. [Learn More](https://lpacwp.com/docs/getting-started/google-cloud-console/places-autocomplete-feature/) [FREE] - Customizable Map container [FREE] - Automatically translated map buttons based on the website's language (set in WordPress' general settings) [FREE] +- Custom Google Maps designs [Pro] +- Custom Marker Icons [Pro] +- Export Order Locations [Pro] +- Multiple Customer Saved Addresses [Pro] +- Shipping cost by distance [Pro] +- Show/Hide Map based on Shipping Zone [Pro] +- Hide Map until a minimum cart total is reached [Pro] +- Hide Map when a maximum cart total is reached [Pro] +- More Map Visibility Rules [Pro] +- Restrict Places Autocomplete feature to selected countries [Pro] - Have a feature in mind? Feel free to submit it on the support forum. - And More @@ -93,7 +103,7 @@ Though the primary focus of the plugin is to allow customers to select accurate ### Misc -- Learn more about the plugin and signup for the Pro waiting least [Here >>>](https://lpacwp.com) +- Learn more about the plugin or Purchase the PRO version [Here >>>](https://lpacwp.com) - Assets [Attribution](https://lpacwp.com/attribution/) This plugin is free software, and the most important features have been kept free and open to use so that all can benefit. If you like the plugin and believe that it's helped grow your business, then please consider [leaving a review](https://wordpress.org/support/plugin/map-location-picker-at-checkout-for-woocommerce/reviews/#new-post). @@ -152,6 +162,16 @@ The save location of QR codes have been changed. Links to QR codes in past order == Changelog == += 1.4.1 = +* [New PRO] Export Order Locations. +* [New PRO] Custom Google Map Designs. +* [New PRO] Custom Google Map Marker Icon. +* [New PRO] Customer Saved Addresses. +* [New PRO] Restrict Places Autocomplete to a specific country. +* [New PRO] Shipping cost by distance. +* [New] PRO version has been released! Dummy PRO options can be seen in the LPAC settings. +* [Fix] Coordinates were not being retrieved when only "Billing Address 1" was selected for the Places Autocomplete field. + = 1.4.0 = * [Change] BREAKING CHANGE: The save location of QR codes created for orders have been changed. Links to QR codes in past order emails will stop working after updating, but QR codes in new orders will work fine. * [New] Added a new Static Map option to the list of link types that can be added to customer emails. (QR Code, Button, Static Map)