From d94f0283ecc6ea352937f87a603edaf3f18a573f Mon Sep 17 00:00:00 2001 From: UVLabs Date: Mon, 27 Sep 2021 01:42:45 -0400 Subject: [PATCH] chore: syncing --- class-lpac-uninstall.php | 2 + includes/admin/class-lpac-admin-settings.php | 625 ++++++++++-------- includes/class-lpac.php | 28 +- .../helpers/class-lpac-functions-helper.php | 36 +- includes/public/class-lpac-public-display.php | 111 +++- includes/public/js/lpac-public.js | 27 +- includes/public/js/maps/checkout-page-map.js | 162 ++++- lpac.php | 6 +- readme.txt | 5 + 9 files changed, 635 insertions(+), 367 deletions(-) diff --git a/class-lpac-uninstall.php b/class-lpac-uninstall.php index e4e4f8a..26125d6 100644 --- a/class-lpac-uninstall.php +++ b/class-lpac-uninstall.php @@ -70,6 +70,8 @@ public static function remove_plugin_settings() { 'lpac_wc_shipping_classes', 'lpac_wc_shipping_classes_show_hide', 'lpac_enable_save_address_feature', + 'lpac_wc_shipping_methods', + 'lpac_hide_troubleshooting_admin_checkout_notice', ); foreach ( $option_keys as $key ) { diff --git a/includes/admin/class-lpac-admin-settings.php b/includes/admin/class-lpac-admin-settings.php index 1ae4b7f..06e2c38 100644 --- a/includes/admin/class-lpac-admin-settings.php +++ b/includes/admin/class-lpac-admin-settings.php @@ -55,7 +55,9 @@ public function __construct() public function lpac_create_plugin_settings_sections() { $sections = array( - '' => __( 'General', 'lpac' ), + 'general' => __( 'General', 'lpac' ), + 'display' => __( 'Display', 'lpac' ), + 'debug' => __( 'Debug', 'lpac' ), 'premium' => __( 'Premium', 'lpac' ), ); // TODO: Allow this section once development of premium features are futher ahead. @@ -104,7 +106,7 @@ private function lpac_create_plugin_settings_banner() $no_api_key = ''; } - $title = __( "Use the Options Below to Change the Plugin's General Settings", 'lpac' ); + $title = __( "Use the Options Below to Change the Plugin's Settings", 'lpac' ); $issues = __( 'If you encounter any issues then please open a support ticket ', 'lpac' ); $issues .= "{$here}"; $issues .= $external_icon; @@ -123,302 +125,365 @@ private function lpac_create_plugin_settings_banner() } /** - * Create the setting options for the plugin. + * House all the plugin settings to do with General. * - * @since 1.0.0 - * @param array $settings The WooCommerce settings. - * @param array $current_section The current settings tab being viewed. + * @return array */ - public function lpac_create_plugin_settings_fields() + public function lpac_create_general_setting_fields() { - global $current_section ; $lpac_settings = array(); - // The default tab("General") has no section id, if it does then it's not the General tab - // And its most likely the "Premium tab" + $lpac_settings[] = array( + 'name' => __( 'LPAC General Settings', 'lpac' ), + 'id' => 'lpac_general_settings', + 'type' => 'title', + 'desc' => $this->lpac_create_plugin_settings_banner(), + ); + $plugin_enabled = get_option( 'lpac_enabled' ); + /* + * If the option doesn't exist then this is most likely a new install, so set the checkbox to checked by default. + * If the option already exists, then use the setting saved in the database. + */ - if ( empty($current_section) ) { + if ( empty($plugin_enabled) ) { $lpac_settings[] = array( - 'name' => __( 'LPAC General Settings', 'lpac' ), - 'id' => 'lpac', - 'type' => 'title', - 'desc' => $this->lpac_create_plugin_settings_banner(), - ); - $plugin_enabled = get_option( 'lpac_enabled' ); - /* - * If the option doesn't exist then this is most likely a new install, so set the checkbox to checked by default. - * If the option already exists, then use the setting saved in the database. - */ - - if ( empty($plugin_enabled) ) { - $lpac_settings[] = array( - 'name' => __( 'Enabled', 'lpac' ), - 'desc' => __( 'Yes', 'lpac' ), - 'desc_tip' => __( 'Enable map on checkout and order details pages.', 'lpac' ), - 'id' => 'lpac_enabled', - 'type' => 'checkbox', - 'css' => 'max-width:80px;', - 'value' => 'yes', - ); - } else { - $lpac_settings[] = array( - 'name' => __( 'Enabled', 'lpac' ), - 'desc' => __( 'Yes', 'lpac' ), - 'desc_tip' => __( 'Enable map on checkout and order details pages.', 'lpac' ), - 'id' => 'lpac_enabled', - 'type' => 'checkbox', - 'css' => 'max-width:80px;', - ); - } - - $lpac_settings[] = array( - 'name' => __( 'Google Maps API Key', 'lpac' ), - 'desc_tip' => __( 'Enter the API key from Google cloud console.', 'lpac' ), - 'desc' => __( 'Enter the API key you copied from the Google Cloud Console. Learn More ', 'lpac' ), - 'id' => 'lpac_google_maps_api_key', - 'type' => 'text', - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Force Use of Map', 'lpac' ), + 'name' => __( 'Enabled', 'lpac' ), 'desc' => __( 'Yes', 'lpac' ), - 'desc_tip' => __( 'Prevent the customer from checking out until they select a location on the map.', 'lpac' ), - 'id' => 'lpac_force_map_use', + 'desc_tip' => __( 'Enable map on checkout and order details pages.', 'lpac' ), + 'id' => 'lpac_enabled', 'type' => 'checkbox', 'css' => 'max-width:80px;', + 'value' => 'yes', ); + } else { $lpac_settings[] = array( - 'name' => __( 'Default Coordinates', 'lpac' ), - 'desc_tip' => __( 'Enter the default latitude and logitude that will be fetched every time the map loads.', 'lpac' ), - 'desc' => __( 'Enter the default latitude and logitude 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.', 'lpac' ), - 'id' => 'lpac_map_starting_coordinates', - 'placeholder' => '14.024519,-60.974876', - 'type' => 'text', - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Default Zoom', 'lpac' ), - 'desc_tip' => __( 'Recommended number is 16.', 'lpac' ), - 'desc' => __( 'Enter the default zoom that will be used every time the map loads.', 'lpac' ), - 'id' => 'lpac_general_map_zoom_level', - 'placeholder' => '16', - 'default' => 3, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Enable Clickable Icons', 'lpac' ), - 'desc_tip' => __( 'Should customers be able to click on icons of different locations that appear on Google Maps? Recommended setting: Disabled', 'lpac' ), - 'desc' => __( 'Yes', 'lpac' ), - 'id' => 'lpac_allow_clicking_on_map_icons', - 'type' => 'checkbox', - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Background Color (HEX)', 'lpac' ), - 'desc' => __( 'Background color of map container (visible while map is loading).', 'lpac' ), - 'id' => 'lpac_map_background_color', - 'type' => 'color', - 'placeholder' => '#eeeeee', - 'default' => '#EEEEEE', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Where Should the Map Appear on the Checkout Page?', 'lpac' ), - 'desc_tip' => __( 'This option displays a map view on the order received page after an order has been placed by a customer.', 'lpac' ), - 'id' => 'lpac_checkout_map_orientation', - 'type' => 'select', - 'options' => array( - 'woocommerce_before_checkout_shipping_form' => __( 'Shipping Address Area - Top', 'lpac' ), - 'woocommerce_after_checkout_shipping_form' => __( 'Shipping Address Area - Bottom (recommended)', 'lpac' ), - 'woocommerce_before_checkout_billing_form' => __( 'Billing Address Area - Top', 'lpac' ), - 'woocommerce_after_checkout_billing_form' => __( 'Billing Address Area - Bottom', 'lpac' ), - ), - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Autofill Billing fields', 'lpac' ), - 'desc_tip' => __( 'Should the billing fields be automatically populated with information pulled from the location?', 'lpac' ), - 'desc' => __( 'Yes', 'lpac' ), - 'id' => 'lpac_autofill_billing_fields', - 'type' => 'checkbox', - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Checkout Page Map Height (in px)', 'lpac' ), - 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), - 'id' => 'lpac_checkout_page_map_height', - 'placeholder' => '400', - 'default' => 400, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Checkout Page Map Width (in %)', 'lpac' ), - 'desc_tip' => __( 'Enter the width of map you\'d like.', 'lpac' ), - 'id' => 'lpac_checkout_page_map_width', - 'placeholder' => '100', - 'default' => 100, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Show Map on the Order Received Page', 'lpac' ), - 'desc_tip' => __( 'This option displays a map view on the order received page after an order has been placed by a customer.', 'lpac' ), - 'id' => 'lpac_display_map_on_order_received_page', - 'type' => 'checkbox', - 'css' => 'min-width:300px;', - 'desc' => __( 'Enable', 'lpac' ), - ); - $lpac_settings[] = array( - 'name' => __( 'Order Received Page Map Height (in px)', 'lpac' ), - 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), - 'id' => 'lpac_order_received_page_map_height', - 'placeholder' => '400', - 'default' => 400, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Order Received Page Map Width (in px)', 'lpac' ), - 'desc_tip' => __( 'Enter the width of map you\'d like.', 'lpac' ), - 'id' => 'lpac_order_received_page_map_width', - 'placeholder' => '100', - 'default' => 100, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Show Map on View Order Page', 'lpac' ), - 'desc_tip' => __( 'This option displays a map view on the order details page in the customer account.', 'lpac' ), - 'id' => 'lpac_display_map_on_view_order_page', - 'type' => 'checkbox', - 'css' => 'min-width:300px;', - 'desc' => __( 'Enable', 'lpac' ), - ); - $lpac_settings[] = array( - 'name' => __( 'View Order Page Map Height (in px)', 'lpac' ), - 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), - 'id' => 'lpac_view_order_page_map_height', - 'placeholder' => '400', - 'default' => 400, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'View Order Page Map Width (in px)', 'lpac' ), - 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), - 'id' => 'lpac_view_order_page_map_width', - 'placeholder' => '100', - 'default' => 100, - 'type' => 'number', - 'css' => 'max-width:80px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Add Map Link to Order Emails?', 'lpac' ), - 'desc_tip' => __( 'Add either a Button or QR Code that links to Google Maps to the order emails.', 'lpac' ), - 'id' => 'lpac_enable_delivery_map_link_in_email', + 'name' => __( 'Enabled', 'lpac' ), 'desc' => __( 'Yes', 'lpac' ), + 'desc_tip' => __( 'Enable map on checkout and order details pages.', 'lpac' ), + 'id' => 'lpac_enabled', 'type' => 'checkbox', - ); - $lpac_settings[] = array( - 'name' => __( 'Link Type', 'lpac' ), - 'desc_tip' => __( 'Add either a button to Google Maps or a QR Code to the order emails.', 'lpac' ), - 'desc' => __( 'QR Codes are saved to your uploads directory at: /wp-content/uploads/lpac-qr-codes/year/month/day/order_id.jpg', 'lpac' ), - 'id' => 'lpac_email_delivery_map_link_type', - 'type' => 'select', - 'options' => array( - 'button' => __( 'Button', 'lpac' ), - 'qr_code' => __( 'QR Code', 'lpac' ), - ), - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Link Location', 'lpac' ), - 'id' => 'lpac_email_delivery_map_link_location', - 'type' => 'select', - 'options' => array( - 'woocommerce_email_before_order_table' => __( 'Before Order Table', 'lpac' ), - 'woocommerce_email_customer_details' => __( 'Before Customer Details', 'lpac' ), - ), - 'css' => 'min-width:300px;', - ); - $lpac_settings[] = array( - 'name' => __( 'Select Emails', 'lpac' ), - 'class' => 'wc-enhanced-select', - 'desc' => __( 'Select the Emails you\'d like this setting to take effect on.', 'lpac' ), - 'id' => 'lpac_email_delivery_map_emails', - 'type' => 'multiselect', - 'options' => array( - 'new_order' => __( 'New Order', 'lpac' ), - 'customer_on_hold_order' => __( 'Order on Hold', 'lpac' ), - 'customer_note' => __( 'Customer Note', 'lpac' ), - 'customer_completed_order' => __( 'Completed Order', 'lpac' ), - 'customer_invoice' => __( 'Customer Invoice', 'lpac' ), - ), - 'css' => 'min-width:300px;height: 100px', - ); - $lpac_settings[] = array( - 'name' => __( 'Shipping Classes', 'lpac' ), - 'class' => 'wc-enhanced-select', - 'desc' => __( 'Select shipping classes. NOTE: These settings apply if ANY of the items in the cart meets the condition.', 'lpac' ), - 'id' => 'lpac_wc_shipping_classes', - 'type' => 'multiselect', - 'options' => Lpac_Functions_Helper::lpac_get_available_shipping_classes(), - 'css' => 'min-width:300px;height: 100px', - ); - $lpac_settings[] = array( - 'name' => __( 'Show or Hide', 'lpac' ), - '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 classes? %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 classes 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 classes selected above.', 'lpac' ), - '
', - '', - '' - ), - 'id' => 'lpac_wc_shipping_classes_show_hide', - 'type' => 'radio', - 'options' => array( - 'show' => __( 'Show', 'lpac' ), - 'hide' => __( 'Hide', 'lpac' ), - ), - ); - $lpac_settings[] = array( - 'name' => __( 'Housekeeping', 'lpac' ), - 'desc_tip' => __( 'Delete all plugin settings on uninstall.', 'lpac' ), - 'id' => 'lpac_delete_settings_on_uninstall', - 'type' => 'checkbox', - ); - // Custom attributes example - // https://woocommerce.github.io/code-reference/files/woocommerce-includes-admin-wc-meta-box-functions.html#source-view.146 - // $lpac_settings[] = array( - // 'name' => __( 'Test', 'lpac' ), - // 'desc_tip' => __( 'Delete all plugin settings on uninstall.', 'lpac' ), - // 'id' => 'lpac_delete_settings_on_uninstall', - // 'type' => 'text', - // 'custom_attributes' => array( - // 'disabled' => 'disabled', - // ) - // ); - // TODO default checkbox - // https://wordpress.stackexchange.com/questions/390270/woocommerce-settings-api-set-checkbox-checked-by-default?noredirect=1#comment567330_390270 - // $lpac_settings[] = array( - // 'name' => __( 'test', 'lpac' ), - // // 'cbvalue' => 'yes', - // // 'value' => 'yes', - // 'desc_tip' => __( 'Should customers be able to click on icons of different locations that appear on Google Maps? Recommended setting: Disabled', 'lpac' ), - // 'desc' => __( 'Yes', 'lpac' ), - // 'id' => 'lpac_test_option', - // 'type' => 'checkbox', - // 'css' => 'min-width:300px;', - // ); - $lpac_settings[] = array( - 'type' => 'sectionend', - 'id' => 'lpac_general_settings_section_end', + 'css' => 'max-width:80px;', ); } + $lpac_settings[] = array( + 'name' => __( 'Google Maps API Key', 'lpac' ), + 'desc_tip' => __( 'Enter the API key from Google cloud console.', 'lpac' ), + 'desc' => __( 'Enter the API key you copied from the Google Cloud Console. Learn More ', 'lpac' ), + 'id' => 'lpac_google_maps_api_key', + 'type' => 'text', + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Force Use of Map', 'lpac' ), + 'desc' => __( 'Yes', 'lpac' ), + 'desc_tip' => __( 'Prevent the customer from checking out until they select a location on the map.', 'lpac' ), + 'id' => 'lpac_force_map_use', + 'type' => 'checkbox', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Default Coordinates', 'lpac' ), + 'desc_tip' => __( 'Enter the default latitude and logitude that will be fetched every time the map loads.', 'lpac' ), + 'desc' => __( 'Enter the default latitude and logitude 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.', 'lpac' ), + 'id' => 'lpac_map_starting_coordinates', + 'placeholder' => '14.024519,-60.974876', + 'type' => 'text', + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Default Zoom', 'lpac' ), + 'desc_tip' => __( 'Recommended number is 16.', 'lpac' ), + 'desc' => __( 'Enter the default zoom that will be used every time the map loads.', 'lpac' ), + 'id' => 'lpac_general_map_zoom_level', + 'placeholder' => '16', + 'default' => 3, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Enable Clickable Icons', 'lpac' ), + 'desc_tip' => __( 'Should customers be able to click on icons of different locations that appear on Google Maps? Recommended setting: Disabled', 'lpac' ), + 'desc' => __( 'Yes', 'lpac' ), + 'id' => 'lpac_allow_clicking_on_map_icons', + 'type' => 'checkbox', + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Autofill Billing fields', 'lpac' ), + 'desc_tip' => __( 'Should the billing fields be automatically populated with information pulled from the location?', 'lpac' ), + 'desc' => __( 'Yes', 'lpac' ), + 'id' => 'lpac_autofill_billing_fields', + 'type' => 'checkbox', + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Show Map on the Order Received Page', 'lpac' ), + 'desc_tip' => __( 'This option displays a map view on the order received page after an order has been placed by a customer.', 'lpac' ), + 'id' => 'lpac_display_map_on_order_received_page', + 'type' => 'checkbox', + 'css' => 'min-width:300px;', + 'desc' => __( 'Enable', 'lpac' ), + ); + $lpac_settings[] = array( + 'name' => __( 'Show Map on View Order Page', 'lpac' ), + 'desc_tip' => __( 'This option displays a map view on the order details page in the customer account.', 'lpac' ), + 'id' => 'lpac_display_map_on_view_order_page', + 'type' => 'checkbox', + 'css' => 'min-width:300px;', + 'desc' => __( 'Enable', 'lpac' ), + ); + $lpac_settings[] = array( + 'name' => __( 'Add Map Link to Order Emails?', 'lpac' ), + 'desc_tip' => __( 'Add either a Button or QR Code that links to Google Maps to the order emails.', 'lpac' ), + 'id' => 'lpac_enable_delivery_map_link_in_email', + 'desc' => __( 'Yes', 'lpac' ), + 'type' => 'checkbox', + ); + $lpac_settings[] = array( + 'name' => __( 'Link Type', 'lpac' ), + 'desc_tip' => __( 'Add either a button to Google Maps or a QR Code to the order emails.', 'lpac' ), + 'desc' => __( 'QR Codes are saved to your uploads directory at: /wp-content/uploads/lpac-qr-codes/year/month/day/order_id.jpg', 'lpac' ), + 'id' => 'lpac_email_delivery_map_link_type', + 'type' => 'select', + 'options' => array( + 'button' => __( 'Button', 'lpac' ), + 'qr_code' => __( 'QR Code', 'lpac' ), + ), + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Link Location', 'lpac' ), + 'id' => 'lpac_email_delivery_map_link_location', + 'type' => 'select', + 'options' => array( + 'woocommerce_email_before_order_table' => __( 'Before Order Table', 'lpac' ), + 'woocommerce_email_customer_details' => __( 'Before Customer Details', 'lpac' ), + ), + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Select Emails', 'lpac' ), + 'class' => 'wc-enhanced-select', + 'desc' => __( 'Select the Emails you\'d like this setting to take effect on.', 'lpac' ), + 'id' => 'lpac_email_delivery_map_emails', + 'type' => 'multiselect', + 'options' => array( + 'new_order' => __( 'New Order', 'lpac' ), + 'customer_on_hold_order' => __( 'Order on Hold', 'lpac' ), + 'customer_note' => __( 'Customer Note', 'lpac' ), + 'customer_completed_order' => __( 'Completed Order', 'lpac' ), + 'customer_invoice' => __( 'Customer Invoice', 'lpac' ), + ), + 'css' => 'min-width:300px;height: 100px', + ); + $lpac_settings[] = array( + 'name' => __( 'Hide Map for Shipping Methods', 'lpac' ), + 'class' => 'wc-enhanced-select', + 'desc' => __( 'Hide the map when any of these shipping methods are chosen by the user.', 'lpac' ), + 'id' => 'lpac_wc_shipping_methods', + 'type' => 'multiselect', + 'options' => Lpac_Functions_Helper::lpac_get_available_shipping_methods(), + 'css' => 'min-width:300px;height: 100px', + ); + $lpac_settings[] = array( + 'name' => __( 'Shipping Classes', 'lpac' ), + 'class' => 'wc-enhanced-select', + 'desc' => __( 'Select shipping classes. NOTE: These settings apply if ANY of the items in the cart meets the condition.', 'lpac' ), + 'id' => 'lpac_wc_shipping_classes', + 'type' => 'multiselect', + 'options' => Lpac_Functions_Helper::lpac_get_available_shipping_classes(), + 'css' => 'min-width:300px;height: 100px', + ); + $lpac_settings[] = array( + 'name' => __( 'Show or Hide', 'lpac' ), + '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 classes? %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 classes 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 classes selected above.', 'lpac' ), + '
', + '', + '' + ), + 'id' => 'lpac_wc_shipping_classes_show_hide', + 'type' => 'radio', + 'options' => array( + 'show' => __( 'Show', 'lpac' ), + 'hide' => __( 'Hide', 'lpac' ), + ), + ); + $lpac_settings[] = array( + 'name' => __( 'Housekeeping', 'lpac' ), + 'desc_tip' => __( 'Delete all plugin settings on uninstall.', 'lpac' ), + 'id' => 'lpac_delete_settings_on_uninstall', + 'type' => 'checkbox', + ); + $lpac_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_general_settings_section_end', + ); + return $lpac_settings; + } + + /** + * House all the plugin settings to do with Display. + * + * @return array + */ + private function lpac_create_display_setting_fields() + { + $lpac_settings = array(); + $lpac_settings[] = array( + 'name' => __( 'LPAC Display Settings', 'lpac' ), + 'id' => 'lpac_display_settings', + 'type' => 'title', + 'desc' => $this->lpac_create_plugin_settings_banner(), + ); + $lpac_settings[] = array( + 'name' => __( 'Background Color (HEX)', 'lpac' ), + 'desc' => __( 'Background color of map container (visible while map is loading).', 'lpac' ), + 'id' => 'lpac_map_background_color', + 'type' => 'color', + 'placeholder' => '#eeeeee', + 'default' => '#EEEEEE', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Where Should the Map Appear on the Checkout Page?', 'lpac' ), + 'desc_tip' => __( 'This option displays a map view on the order received page after an order has been placed by a customer.', 'lpac' ), + 'id' => 'lpac_checkout_map_orientation', + 'type' => 'select', + 'options' => array( + 'woocommerce_before_checkout_shipping_form' => __( 'Shipping Address Area - Top', 'lpac' ), + 'woocommerce_after_checkout_shipping_form' => __( 'Shipping Address Area - Bottom (recommended)', 'lpac' ), + 'woocommerce_before_checkout_billing_form' => __( 'Billing Address Area - Top', 'lpac' ), + 'woocommerce_after_checkout_billing_form' => __( 'Billing Address Area - Bottom', 'lpac' ), + ), + 'css' => 'min-width:300px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Checkout Page Map Width (in %)', 'lpac' ), + 'desc_tip' => __( 'Enter the width of map you\'d like.', 'lpac' ), + 'id' => 'lpac_checkout_page_map_width', + 'placeholder' => '100', + 'default' => 100, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Checkout Page Map Height (in px)', 'lpac' ), + 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), + 'id' => 'lpac_checkout_page_map_height', + 'placeholder' => '400', + 'default' => 400, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Order Received Page Map Height (in px)', 'lpac' ), + 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), + 'id' => 'lpac_order_received_page_map_height', + 'placeholder' => '400', + 'default' => 400, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'Order Received Page Map Width (in px)', 'lpac' ), + 'desc_tip' => __( 'Enter the width of map you\'d like.', 'lpac' ), + 'id' => 'lpac_order_received_page_map_width', + 'placeholder' => '100', + 'default' => 100, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'View Order Page Map Height (in px)', 'lpac' ), + 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), + 'id' => 'lpac_view_order_page_map_height', + 'placeholder' => '400', + 'default' => 400, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'name' => __( 'View Order Page Map Width (in px)', 'lpac' ), + 'desc_tip' => __( 'Enter the height of map you\'d like.', 'lpac' ), + 'id' => 'lpac_view_order_page_map_width', + 'placeholder' => '100', + 'default' => 100, + 'type' => 'number', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_display_settings_section_end', + ); + return $lpac_settings; + } + + /** + * House all the plugin settings to do with Debugging. + * + * @return array + */ + private function lpac_create_debug_setting_fields() + { + $lpac_settings = array(); + $lpac_settings[] = array( + 'name' => __( 'LPAC Debug Settings', 'lpac' ), + 'id' => 'lpac_debug_settings', + 'type' => 'title', + 'desc' => $this->lpac_create_plugin_settings_banner(), + ); + $lpac_settings[] = array( + 'name' => __( 'Hide checkout notice', 'lpac' ), + 'desc' => __( 'Yes', 'lpac' ), + 'desc_tip' => __( 'Hide the admin checkout notice.', 'lpac' ), + 'id' => 'lpac_hide_troubleshooting_admin_checkout_notice', + 'type' => 'checkbox', + 'css' => 'max-width:80px;', + ); + $lpac_settings[] = array( + 'type' => 'sectionend', + 'id' => 'lpac_debug_settings_section_end', + ); + return $lpac_settings; + } + + /** + * Create the setting options for the plugin. + * + * @since 1.0.0 + * @param array $settings The WooCommerce settings. + * @param array $current_section The current settings tab being viewed. + */ + public function lpac_create_plugin_settings_fields() + { + global $current_section ; + $lpac_settings = array(); + if ( empty($current_section) || $current_section === 'general' ) { + $lpac_settings = $this->lpac_create_general_setting_fields(); + } + if ( $current_section === 'display' ) { + $lpac_settings = $this->lpac_create_display_setting_fields(); + } + if ( $current_section === 'debug' ) { + $lpac_settings = $this->lpac_create_debug_setting_fields(); + } if ( $current_section === 'premium' ) { } + // Custom attributes example + // https://woocommerce.github.io/code-reference/files/woocommerce-includes-admin-wc-meta-box-functions.html#source-view.146 + // $lpac_settings[] = array( + // 'name' => __( 'Test', 'lpac' ), + // 'desc_tip' => __( 'Delete all plugin settings on uninstall.', 'lpac' ), + // 'id' => 'lpac_delete_settings_on_uninstall', + // 'type' => 'text', + // 'custom_attributes' => array( + // 'disabled' => 'disabled', + // ) + // ); + // Default checkbox example + // https://wordpress.stackexchange.com/questions/390270/woocommerce-settings-api-set-checkbox-checked-by-default?noredirect=1#comment567330_390270 return apply_filters( 'woocommerce_get_settings_' . $this->id, $lpac_settings ); } diff --git a/includes/class-lpac.php b/includes/class-lpac.php index 1196420..64c9218 100644 --- a/includes/class-lpac.php +++ b/includes/class-lpac.php @@ -197,36 +197,17 @@ private function define_public_hooks() $plugin_public = new Lpac_Public( $this->get_plugin_name(), $this->get_version() ); $plugin_public_display = new Lpac_Public_Display(); $functions_helper = new Lpac_Functions_Helper(); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); /* - * WooCommerce + * If plugin not enabled don't continue */ $plugin_enabled = get_option( 'lpac_enabled', 'yes' ); if ( $plugin_enabled === 'no' ) { return; } + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); $this->loader->add_action( 'wp_head', $plugin_public_display, 'lpac_output_map_custom_styles' ); $checkout_page_map_location = get_option( 'lpac_checkout_map_orientation', 'woocommerce_after_checkout_shipping_form' ); - /* - * Update old options. - */ - //TODO Delete this block when confident most users have updated. - - if ( $checkout_page_map_location === 'billing_address_area_top' ) { - $checkout_page_map_location = 'woocommerce_before_checkout_billing_form'; - update_option( 'lpac_checkout_map_orientation', 'woocommerce_before_checkout_billing_form' ); - } elseif ( $checkout_page_map_location === 'billing_address_area_bottom' ) { - $checkout_page_map_location = 'woocommerce_after_checkout_billing_form'; - update_option( 'lpac_checkout_map_orientation', 'woocommerce_after_checkout_billing_form' ); - } elseif ( $checkout_page_map_location === 'shipping_address_area_top' ) { - $checkout_page_map_location = 'woocommerce_before_checkout_shipping_form'; - update_option( 'lpac_checkout_map_orientation', 'woocommerce_before_checkout_shipping_form' ); - } elseif ( $checkout_page_map_location === 'shipping_address_area_bottom' ) { - $checkout_page_map_location = 'woocommerce_after_checkout_shipping_form'; - update_option( 'lpac_checkout_map_orientation', 'woocommerce_after_checkout_shipping_form' ); - } - /* * Output hidden input fields for latitude and longitude. */ @@ -273,7 +254,8 @@ private function define_public_hooks() 4 ); } - + + $this->loader->add_action( 'woocommerce_before_checkout_form', $plugin_public_display, 'lpac_add_admin_checkout_notice' ); } /** diff --git a/includes/helpers/class-lpac-functions-helper.php b/includes/helpers/class-lpac-functions-helper.php index c32b4c7..7a8477c 100644 --- a/includes/helpers/class-lpac-functions-helper.php +++ b/includes/helpers/class-lpac-functions-helper.php @@ -119,17 +119,17 @@ public static function lpac_get_qr_codes_directory( $base ) */ public static function lpac_get_available_shipping_classes() { - $normalized_shipping_classes = array(); if ( !class_exists( 'WC_Shipping' ) ) { error_log( 'Location Picker at Checkout for WooCommerce: WC_Shipping() class not found.' ); - return $normalized_shipping_classes; + return array(); } $lpac_wc_shipping_classes = ( new WC_Shipping() )->get_shipping_classes(); if ( !is_array( $lpac_wc_shipping_classes ) ) { - return $normalized_shipping_classes; + return array(); } + $normalized_shipping_classes = array(); foreach ( $lpac_wc_shipping_classes as $shipping_class_object ) { $iterated_shipping_class = array( $shipping_class_object->term_id => $shipping_class_object->name, @@ -154,6 +154,9 @@ public static function lpac_get_available_shipping_classes() public static function lpac_get_order_shipping_classes() { $cart = WC()->cart->get_cart(); + if ( !is_array( $cart ) ) { + return array(); + } $shipping_class_array = array(); foreach ( $cart as $cart_item ) { $shipping_class_id = $cart_item['data']->get_shipping_class_id(); @@ -162,5 +165,32 @@ public static function lpac_get_order_shipping_classes() } return $shipping_class_array; } + + /** + * + * Get all available shipping methods from the shipping zones created by users. + * + * @return array + */ + public static function lpac_get_available_shipping_methods() + { + + if ( !class_exists( 'WC_Shipping_Zones' ) ) { + error_log( 'Location Picker at Checkout for WooCommerce: WC_Shipping_Zones() class not found.' ); + return array(); + } + + $zones = WC_Shipping_Zones::get_zones(); + if ( !is_array( $zones ) ) { + return array(); + } + $shipping_methods = array_column( $zones, 'shipping_methods' ); + $flatten = array_merge( ...$shipping_methods ); + $normalized_shipping_methods = array(); + foreach ( $flatten as $key => $class ) { + $normalized_shipping_methods[$class->id] = $class->method_title; + } + return $normalized_shipping_methods; + } } \ No newline at end of file diff --git a/includes/public/class-lpac-public-display.php b/includes/public/class-lpac-public-display.php index ab62f25..845716e 100644 --- a/includes/public/class-lpac-public-display.php +++ b/includes/public/class-lpac-public-display.php @@ -41,14 +41,20 @@ public function __construct() { private function lpac_expose_map_settings_js( $additional = array() ) { $js_variables = $this->lpac_get_map_settings(); - $js_variables = array_merge( $js_variables, $additional ); $map_options = json_encode( $js_variables ); + /** + * Shipping methods Admin has decided to hide the map for. + */ + $disallowed_shipping_methods = get_option( 'lpac_wc_shipping_methods', array() ); + $disallowed_shipping_methods = json_encode( $disallowed_shipping_methods ); + $global_variables = <<lpac_global_map_settings_js = $global_variables; @@ -72,15 +78,39 @@ public function lpac_output_map_on_checkout_page() { $instuctions_text = __( 'Click the "Detect Current Location" button then move the red marker to your desired shipping address.', 'lpac' ); $instuctions_text = apply_filters( 'lpac_map_instuctions_text', $instuctions_text ); + $user_id = (int) get_current_user_id(); + + $saved_addresses_area = apply_filters( 'lpac_saved_addresses', '', $user_id ); + $saved_addresses_area = wp_kses_post( $saved_addresses_area ); + + $before_map_filter = apply_filters( 'lpac_before_map', '', $user_id ); + $before_map_filter = wp_kses_post( $before_map_filter ); + + $after_map_filter = apply_filters( 'lpac_after_map', '', $user_id ); + $after_map_filter = wp_kses_post( $after_map_filter ); + + $before_map_controls_filter = apply_filters( 'lpac_before_map_controls', '', $user_id ); + $before_map_controls_filter = wp_kses_post( $before_map_controls_filter ); + + $after_map_controls_filter = apply_filters( 'lpac_after_map_controls', '', $user_id ); + $after_map_controls_filter = wp_kses_post( $after_map_controls_filter ); + $markup = << -
-
$instuctions_text
- +
+ $before_map_filter +
+ $after_map_filter +
+ $before_map_controls_filter +
$instuctions_text
+ +
    $saved_addresses_area
+ $after_map_controls_filter +
MAP; - echo $markup; + echo apply_filters( 'lpac_map_markup', $markup, $user_id ); // Add inline global JS so that we can use data fetched using PHP inside JS wp_add_inline_script( LPAC_PLUGIN_NAME . '-base-map', $this->lpac_global_map_settings_js, 'before' ); @@ -94,7 +124,7 @@ public function lpac_output_map_on_checkout_page() { */ public function lpac_output_map_on_order_details_page() { - global $woocommerce, $wp; + global $wp; // If this isn't the order received page shown after a purchase, or the view order page shown on the user account, then bail. if ( ! is_wc_endpoint_url( 'view-order' ) && ! is_wc_endpoint_url( 'order-received' ) ) { @@ -139,8 +169,8 @@ public function lpac_output_map_on_order_details_page() { $this->lpac_expose_map_settings_js( $user_location_collected_during_order ); $markup = <<
-
+
+
MAP; @@ -185,15 +215,30 @@ public function lpac_create_lat_and_long_inputs( $fields ) { * * @since 1.1.0 * @param array $order_id The order id. + * + * @return void */ - public function lpac_validate_location_fields( $fields, $errors ) : void { + public function lpac_validate_location_fields( $fields, $errors ) { + /** + * The map visibility might be changed via JS or other conditions + * So we need to check if its actually shown before trying to validate + */ $map_shown = (bool) $fields['lpac_is_map_shown']; if ( $map_shown === false ) { return; } + /** + * Allow users to override this setting + */ + $custom_override = apply_filters( 'lpac_override_map_validation', false, $fields, $errors ); + + if ( $custom_override === true ) { + return; + } + $error_msg = '' . __( 'Please select your location using the Google Map.', 'lpac' ) . ''; $error_msg = apply_filters( 'lpac_checkout_empty_cords_error_msg', $error_msg ); @@ -212,13 +257,19 @@ public function lpac_validate_location_fields( $fields, $errors ) : void { */ public function lpac_save_cords_order_meta( $order_id ) { - $latitude = ( isset( $_POST['lpac_latitude'] ) ) ? $_POST['lpac_latitude'] : ''; - $longitude = ( isset( $_POST['lpac_longitude'] ) ) ? $_POST['lpac_longitude'] : ''; + $latitude = $_POST['lpac_latitude'] ?? ''; + $longitude = $_POST['lpac_longitude'] ?? ''; + $map_shown = $_POST['lpac_is_map_shown'] ?? ''; if ( empty( $latitude ) || empty( $longitude ) ) { return; } + // If the map was not shown for this order don't save the coordinates. + if ( empty( $map_shown ) ) { + return; + } + update_post_meta( $order_id, '_lpac_latitude', sanitize_text_field( $_POST['lpac_latitude'] ) ); update_post_meta( $order_id, '_lpac_longitude', sanitize_text_field( $_POST['lpac_longitude'] ) ); } @@ -347,4 +398,40 @@ public function lpac_add_delivery_location_link_to_email( $order, $sent_to_admin } + public function lpac_add_admin_checkout_notice() { + + $hide_notice = get_option( 'lpac_hide_troubleshooting_admin_checkout_notice', 'no' ); + + if ( $hide_notice === 'yes' ) { + return; + } + + $user_id = get_current_user_id(); + + if ( empty( $user_id ) ) { + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + + $notice_text = esc_html__( 'Hi Admin, some websites might have issues with displaying or using the Google Map. If you\'re having issues then please have a look at your browser console for any errors.' ); + $additional = esc_html__( 'Only Admins on your website can see this notice. You can turn it off in the plugin settings if everything works fine.' ); + + $markup = << +

LPAC: + $notice_text +

+

+ $additional +

+
+MARKUP; + + echo $markup; + + } + } diff --git a/includes/public/js/lpac-public.js b/includes/public/js/lpac-public.js index d735269..ea4b4ec 100644 --- a/includes/public/js/lpac-public.js +++ b/includes/public/js/lpac-public.js @@ -28,26 +28,31 @@ * Although scripts in the WordPress core, Plugins and Themes may be * practising this, we should strive to set a better example in our own work. */ - + // TODO Can most likely merge this into checkout-page-map.js $( document ).ready( + function(){ - var map_div = document.querySelector( '.lpac-map' ); - var lat = document.querySelector( '#lpac_latitude_field' ); - var long = document.querySelector( '#lpac_longitude_field' ); + var map_div = document.querySelector( '#lpac-map-container' ); var map_shown = document.querySelector( '#lpac_is_map_shown' ); + var map_present = true; + var map_visibility = ''; - if( typeof(map_shown) === 'undefined' || map_shown === null ){ - console.log('LPAC: map_shown object not present, skipping...') + if( typeof( map_shown ) === 'undefined' || map_shown === null ){ + console.log('LPAC: map_shown object not present, skipping...'); return; } - if ( ! map_div ) { + /** + * Detect if map is present and the display property + */ + if( typeof( map_div ) === 'undefined' || map_div === null ){ + map_present = false; + }else{ + map_visibility = map_div.style.display; + } - if ( lat && long ) { - lat.remove(); - long.remove(); - } + if ( map_present === false || map_visibility === 'none' ) { if ( map_shown ) { map_shown.value = 0 diff --git a/includes/public/js/maps/checkout-page-map.js b/includes/public/js/maps/checkout-page-map.js index f9cb3ed..887bb65 100644 --- a/includes/public/js/maps/checkout-page-map.js +++ b/includes/public/js/maps/checkout-page-map.js @@ -4,52 +4,52 @@ // https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions // }) -const geocoder = new google.maps.Geocoder() -const infowindow = new google.maps.InfoWindow() + const geocoder = new google.maps.Geocoder() + const infowindow = new google.maps.InfoWindow() -const find_location_btn = document.querySelector( "#lpac-find-location-btn" ); + const find_location_btn = document.querySelector( "#lpac-find-location-btn" ); -if( typeof(find_location_btn) !== 'undefined' && find_location_btn !== null ){ - find_location_btn.addEventListener( - "click", - () => { - lpac_bootstrap_map_functionality( geocoder, map, infowindow ) - } - ) -}else{ - console.log('LPAC: Detect location button not present, skipping...') -} + if( typeof(find_location_btn) !== 'undefined' && find_location_btn !== null ){ + find_location_btn.addEventListener( + "click", + () => { + lpac_bootstrap_map_functionality( geocoder, map, infowindow ) + } + ) + }else{ + console.log('LPAC: Detect location button not present, skipping...') + } -function get_navigator_coordinates() { + function get_navigator_coordinates() { - return new Promise( - function(resolve, reject) { + return new Promise( + function(resolve, reject) { - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition( resolve, reject ) - } else { - // TODO add input fields so users can change this text - alert( 'Geolocation is not possible on this web browser. Please switch to a different web browser to use our interactive map.' ); - } + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition( resolve, reject ) + } else { + // TODO add input fields so users can change this text + alert( 'Geolocation is not possible on this web browser. Please switch to a different web browser to use our interactive map.' ); + } - } - ).catch( - function(error){ + } + ).catch( + function(error){ - console.log( 'Location Picker At Checkout Plugin: ' + error.message ) + console.log( 'Location Picker At Checkout Plugin: ' + error.message ) - if ( error.code === 1 ) { - // TODO add input fields so users can change this text - alert( "Something went wrong while trying to detect your location. Click on the location icon in the address bar and allow our website to detect your location. Please contact us if you need additional assistance." ); - return - } + if ( error.code === 1 ) { + // TODO add input fields so users can change this text + alert( "Something went wrong while trying to detect your location. Click on the location icon in the address bar and allow our website to detect your location. Please contact us if you need additional assistance." ); + return + } - alert( error.message ); + alert( error.message ); - } - ) + } + ) -} + } /** * @@ -67,6 +67,13 @@ function get_navigator_coordinates() { * */ + /** + * Setup our conditional hiding of map based on selected shipping methods; + * + * Running this function as soon as the page loads allows map to be hidden quicker than on document ready event. + */ + lpac_hide_show_map_by_shipping_method(); + /** * Bootstrap the functionality of the map and marker. */ @@ -602,3 +609,88 @@ function get_navigator_coordinates() { billing_zipcode.value = lpac_get_zip_code( results ); } + + /** + * Show or hide the map based ons hipping method selected + */ + function lpac_hide_show_map_by_shipping_method(){ + + const lpacShippingMethods = document.querySelectorAll('#shipping_method .shipping_method'); + + if( typeof( lpacShippingMethods ) === 'undefined' || lpacShippingMethods === null ){ + console.log('LPAC: Cannot find shipping methods element, skipping...'); + return; + } + + // This saved_disallowed_shipping_methods option is in the global JS scope + // See Lpac_Public_Display::lpac_expose_map_settings_js() + const disallowed_shipping_methods = saved_disallowed_shipping_methods; + + let show = true; + + loop1: + for ( const lpacShippingMethod of lpacShippingMethods ){ + + // We have to check for the hidden type as well because if only one shipping method is available WC doesn't show radio buttons. + if( lpacShippingMethod.checked || lpacShippingMethod.type === 'hidden' ){ + + loop2: + for ( const disallowed_shipping_method of disallowed_shipping_methods ){ + + if( lpacShippingMethod.value.indexOf( disallowed_shipping_method ) >= 0 ){ + show = false; + break loop1; + } + + } + + } + + } + + if( show ){ + document.querySelector('#lpac-map-container').style.display = "block"; + document.querySelector('#lpac_is_map_shown').value = 1; + }else{ + document.querySelector('#lpac-map-container').style.display = "none"; + document.querySelector('#lpac_is_map_shown').value = 0; + } + + } + + /** + * Detect the shipping method on page load + * + * This function isn't in use. It causes a slight flicker of the map due to the interval checking + * Function remains in place for debugging purposes. + * + */ + function lpac_setup_changed_shipping_method_on_load(){ + + let stateCheck = setInterval(() => { + if (document.readyState === 'complete') { + lpac_hide_show_map_by_shipping_method(); + clearInterval(stateCheck); + } + console.log('checking..'); + }, 100); + + } + + /** + * Detect when shipping methods are changed based on WC custom updated_checkout event. + * This event can't be accessed via vanilla JS but is the most reliable for performing this action. + */ + (function( $ ) { + 'use strict'; + + $( document ).ready( + function(){ + + $( document.body ).on( 'updated_checkout', lpac_hide_show_map_by_shipping_method ); + + } + ); + + })( jQuery ); + \ No newline at end of file diff --git a/lpac.php b/lpac.php index 863d735..d70cda5 100644 --- a/lpac.php +++ b/lpac.php @@ -16,7 +16,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.2.1 + * Version: 1.2.2 * Author: Uriahs Victor * Author URI: https://uriahsvictor.com * License: GPL-2.0+ @@ -24,7 +24,7 @@ * Text Domain: lpac * Domain Path: /languages * WC requires at least: 3.0 - * WC tested up to: 5.5 + * WC tested up to: 5.7 * Requires PHP: 7.0 */ // If this file is called directly, abort. @@ -76,7 +76,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.2.1' ); +define( 'LPAC_VERSION', '1.2.2' ); define( 'LPAC_PLUGIN_NAME', 'lpac' ); define( 'LPAC_PLUGIN_DIR', __DIR__ ); define( 'LPAC_PLUGIN_PATH_URL', plugin_dir_url( __FILE__ ) ); diff --git a/readme.txt b/readme.txt index 7383655..a795621 100644 --- a/readme.txt +++ b/readme.txt @@ -75,6 +75,11 @@ Ensure that you have setup the plugin with your API key by going to WordPress Da == Changelog == += 1.2.2 = +* [New] Added a new option in settings to hide the map based on the chosen shipping method. +* [Improvement] Better plugin settings arrangement. +* [Info] Tested on WC 5.7. + = 1.2.1 = * [Improvement] Better assign coordinates input fields variables on checkout page.