Changeset 2689830
- Timestamp:
- 03/07/2022 07:21:28 AM (4 years ago)
- Location:
- wc-pickup-store
- Files:
-
- 38 added
- 4 edited
-
tags/1.8.2 (added)
-
tags/1.8.2/assets (added)
-
tags/1.8.2/assets/css (added)
-
tags/1.8.2/assets/css/stores.css (added)
-
tags/1.8.2/assets/css/stores.min.css (added)
-
tags/1.8.2/assets/images (added)
-
tags/1.8.2/assets/images/icon_waze.svg (added)
-
tags/1.8.2/assets/images/wps_placeholder.png (added)
-
tags/1.8.2/assets/js (added)
-
tags/1.8.2/assets/js/stores.js (added)
-
tags/1.8.2/assets/js/stores.min.js (added)
-
tags/1.8.2/includes (added)
-
tags/1.8.2/includes/admin (added)
-
tags/1.8.2/includes/admin/wps-admin.php (added)
-
tags/1.8.2/includes/admin/wps-settings.php (added)
-
tags/1.8.2/includes/class-wps-init.php (added)
-
tags/1.8.2/includes/cpt-store.php (added)
-
tags/1.8.2/includes/integrations (added)
-
tags/1.8.2/includes/integrations/class-vc_stores.php (added)
-
tags/1.8.2/includes/integrations/class-widget-stores.php (added)
-
tags/1.8.2/includes/wps-functions.php (added)
-
tags/1.8.2/index.php (added)
-
tags/1.8.2/languages (added)
-
tags/1.8.2/languages/wc-pickup-store-es_CR.mo (added)
-
tags/1.8.2/languages/wc-pickup-store-es_CR.po (added)
-
tags/1.8.2/languages/wc-pickup-store-es_ES.mo (added)
-
tags/1.8.2/languages/wc-pickup-store-es_ES.po (added)
-
tags/1.8.2/languages/wc-pickup-store-fr_FR.mo (added)
-
tags/1.8.2/languages/wc-pickup-store-fr_FR.po (added)
-
tags/1.8.2/languages/wc-pickup-store.pot (added)
-
tags/1.8.2/readme.txt (added)
-
tags/1.8.2/templates (added)
-
tags/1.8.2/templates/archive-store.php (added)
-
tags/1.8.2/templates/selected-store-details.php (added)
-
tags/1.8.2/templates/single-store.php (added)
-
tags/1.8.2/templates/wrapper-store.php (added)
-
tags/1.8.2/templates/wrapper-vc_stores.php (added)
-
tags/1.8.2/wc-pickup-store.php (added)
-
trunk/includes/cpt-store.php (modified) (3 diffs)
-
trunk/includes/wps-functions.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/wc-pickup-store.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wc-pickup-store/trunk/includes/cpt-store.php
r2679602 r2689830 273 273 * Check if multicountries are allowed and return data 274 274 * Update to disable country filtering 275 * 276 * @since 1.6.0 277 * @version 1.8.2 275 278 */ 276 279 function wps_check_countries_count($only_validate = true) { 277 $country_filtering = (isset(WPS()->country_filtering) && WPS()->country_filtering == 'yes') ? true : false; 278 279 if (apply_filters('wps_disable_country_filtering', $country_filtering)) { 280 return; 281 } 282 283 if (count(get_option('woocommerce_specific_allowed_countries')) > 1) { 284 if ($only_validate) { 285 return true; 280 if ( ! wps_is_country_filtering_disabled() ) { 281 $specific_allowed_countries = get_option( 'woocommerce_specific_allowed_countries' ); 282 283 if ( count( $specific_allowed_countries ) > 1 ) { 284 if ( $only_validate ) { 285 return true; 286 } 287 288 $allowed_countries = array(); 289 foreach ( $specific_allowed_countries as $key => $country_code ) { 290 $allowed_countries[] = array( 291 'code' => $country_code, 292 'name' => WC()->countries->countries[ $country_code ] 293 ); 294 } 295 296 return $allowed_countries; 286 297 } 287 288 $allowed_countries = array();289 foreach (get_option('woocommerce_specific_allowed_countries') as $key => $country_code) {290 $allowed_countries[] = array(291 'code' => $country_code,292 'name' => WC()->countries->countries[$country_code]293 );294 }295 return $allowed_countries;296 298 } 297 299 … … 340 342 /** 341 343 * Update stores without Country 344 * 345 * @since 1.5.25 346 * @version 1.8.2 342 347 */ 343 348 function wps_update_stores_without_country() { 344 if (isset($_GET['update_country']) && $_GET['update_country'] == 1 && !get_option('wps_countries_updated')) { 349 $stores_without_country = wps_check_stores_without_country(); 350 351 if ( $stores_without_country ) { 352 if ( isset( $_GET['update_country'] ) && $_GET['update_country'] == 1 && ! get_option( 'wps_countries_updated' ) ) { 353 foreach ( $stores_without_country as $store_id => $store_data ) { 354 update_post_meta( $store_id, 'store_country', wps_get_wc_default_country() ); 355 } 356 update_option('wps_countries_updated', 1); 357 ?> 358 <div id="message" class="notice notice-info is-dismissible"> 359 <p><?php 360 printf( 361 __('Since version %1$s, a new Country validation was added to %2$s and all stores have been updated.', 'wc-pickup-store'), 362 '<strong>1.5.24</strong>', 363 '<strong>WC Pickup Store</strong>' 364 ); 365 ?></p> 366 </div> 367 <?php 368 } 369 } 370 } 371 add_action( 'init', 'wps_update_stores_without_country' ); 372 373 /** 374 * Check if country filtering is disabled 375 * 376 * @version 1.8.2 377 * 378 * @return bool True or false if this is disabled via admin page or filter 379 */ 380 function wps_is_country_filtering_disabled() { 381 $country_filtering = ( isset( WPS()->country_filtering ) && WPS()->country_filtering == 'yes' ) ? true : false; 382 383 return apply_filters( 'wps_disable_country_filtering', $country_filtering ); 384 } 385 386 /** 387 * Check for stores without country 388 * 389 * @version 1.8.2 390 * 391 * @return bool|array Array of stores without country or false if filtering is disabled 392 */ 393 function wps_check_stores_without_country() { 394 if ( ! wps_is_country_filtering_disabled() ) { 345 395 $stores_without_country = wps_store_get_store_admin(true, array( 346 396 'meta_query' => array( … … 351 401 ) 352 402 ) 353 )); 354 355 foreach ($stores_without_country as $store_id => $store_data) { 356 update_post_meta($store_id, 'store_country', wps_get_wc_default_country()); 357 } 358 update_option('wps_countries_updated', 1); 359 ?> 360 <div id="message" class="notice notice-info is-dismissible"> 361 <p><?php 362 printf( 363 __('Since version %1$s, a new Country validation was added to %2$s and all stores have been updated.', 'wc-pickup-store'), 364 '<strong>1.5.24</strong>', 365 '<strong>WC Pickup Store</strong>' 366 ); 367 ?></p> 368 </div> 369 <?php 370 } 371 } 372 add_action( 'init', 'wps_update_stores_without_country' ); 403 ) ); 404 405 return $stores_without_country; 406 } 407 408 return false; 409 } 373 410 374 411 /** -
wc-pickup-store/trunk/includes/wps-functions.php
r2679602 r2689830 25 25 $ship_to_store = !empty($post_data['shipping_by_store']) ? $post_data['shipping_by_store'] : ''; 26 26 27 if ( wps_check_countries_count()) {28 $country_to_filter = ( isset($post_data['ship_to_different_address'])) ? $post_data['shipping_country'] : $post_data['billing_country'];29 $get_stores = wps_stores_filtering_by_country( $country_to_filter);27 if ( wps_check_countries_count() ) { 28 $country_to_filter = ( isset( $post_data['ship_to_different_address'] ) ) ? $post_data['shipping_country'] : ( isset( $post_data['billing_country'] ) ? $post_data['billing_country'] : wps_get_wc_default_country() ); 29 $get_stores = wps_stores_filtering_by_country( $country_to_filter ); 30 30 } else { 31 31 $get_stores = wps_store_get_store_admin(true); … … 176 176 /** 177 177 * Get chosen shipping method 178 * 179 * @since 1.5.x 180 * @version 1.8.2 181 * 182 * @return array Chosen shipping methods or empty array 178 183 */ 179 184 function wps_get_chosen_shipping_method() { 180 $chosen_methods = WC()->session->get( 'chosen_shipping_methods');181 182 return $chosen_methods[0];185 $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); 186 187 return is_array( $chosen_methods ) ? $chosen_methods[0] : array(); 183 188 } 184 189 … … 191 196 $chosen_shipping = wps_get_chosen_shipping_method(); 192 197 193 return in_array( $chosen_shipping, array(WPS()->id));198 return in_array( $chosen_shipping, array( WPS()->id ) ); 194 199 } 195 200 -
wc-pickup-store/trunk/readme.txt
r2685521 r2689830 5 5 Requires at least: 4.7 6 6 Tested up to: 5.9.1 7 Stable tag: 1.8. 17 Stable tag: 1.8.2 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 99 99 View more information about tax handling in [this documentation](https://keylormendoza.com/how-to/tax-handling-by-stores/) 100 100 101 = How can I manage tax options for this shipping method? =102 101 103 102 == Screenshots == … … 123 122 124 123 == Changelog == 124 = 1.8.2 = 125 * Fix: Multisite validation if WC plugin is not active 126 * Improvement: Validations with country filtering notice and functionality 127 * Fix: Undefinded value in function wps_store_row_layout with variable $country_to_filter 128 * Fix: Condition to prevent undefined variable in function wps_get_chosen_shipping_method 129 125 130 = 1.8.1 = 126 131 * Improvement: Admin notices for validations … … 283 288 284 289 == Upgrade Notice == 290 = 1.8.2 = 291 * Important Fix: Multisite validation if WC plugin is not active 292 285 293 = 1.8.0 = 286 294 * New: Filters for admin options page -
wc-pickup-store/trunk/wc-pickup-store.php
r2685521 r2689830 4 4 * Plugin URI: https://www.keylormendoza.com/plugins/wc-pickup-store/ 5 5 * Description: Allows you to set up a custom post type for stores available to use it as shipping method Local pickup in WooCommerce. It also allows your clients to choose an store on the Checkout page and also adds the store fields to the order details and email. 6 * Version: 1.8. 16 * Version: 1.8.2 7 7 * Requires at least: 4.7 8 8 * Tested up to: 5.9.1 … … 22 22 23 23 if ( !defined( 'WPS_PLUGIN_VERSION' ) ) { 24 define( 'WPS_PLUGIN_VERSION', '1.8. 1' );24 define( 'WPS_PLUGIN_VERSION', '1.8.2' ); 25 25 } 26 26 … … 35 35 /** 36 36 * Admin Notices 37 * 38 * @since 1.0.0 39 * @version 1.8.2 37 40 */ 38 function wps_store_custom_admin_notices() { 41 if ( ! in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) ) { 42 add_action('admin_notices', 'wps_store_check_init_notice'); 43 return; 44 } 45 46 function wps_store_check_init_notice() { 39 47 // Check if WooCommerce is active 40 if ( current_user_can( 'activate_plugins') && !is_plugin_active( 'woocommerce/woocommerce.php' )) {48 if ( current_user_can( 'activate_plugins') ) { 41 49 ?> 42 50 <div id="message" class="error"> … … 55 63 return; 56 64 } 65 } 57 66 67 function wps_store_country_notice() { 58 68 // Update stores Country 59 if ( version_compare( WPS_PLUGIN_VERSION, '1.5.24' ) >= 0 ) {69 if ( version_compare( WPS_PLUGIN_VERSION, '1.5.24' ) >= 0 && wps_check_stores_without_country() && count( wps_check_stores_without_country() ) > 0 ) { 60 70 if ( !get_option( 'wps_countries_updated' ) ) { 61 71 ?> … … 78 88 } 79 89 } 80 add_action( 'admin_notices', 'wps_store_c ustom_admin_notices' );90 add_action( 'admin_notices', 'wps_store_country_notice' ); 81 91 82 92 /**
Note: See TracChangeset
for help on using the changeset viewer.