-
Notifications
You must be signed in to change notification settings - Fork 0
/
departamentos-y-ciudades-de-colombia-para-woocommerce.php
73 lines (56 loc) · 2.25 KB
/
departamentos-y-ciudades-de-colombia-para-woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Plugin Name: Departamentos y Ciudades de Colombia para Woocommerce
* Description: Plugin modificado con los departamentos y ciudades de Colombia
* Version: 2.0.5
* Author: Saul Morales Pacheco
* Author URI: https://saulmoralespa.com
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: departamentos-y-ciudades-de-colombia-para-woocommerce
* Domain Path: /languages
* WC tested up to: 6.0
* WC requires at least: 4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action('plugins_loaded','states_places_colombia_init',1);
function states_places_colombia_smp_notices($classes, $notice){
?>
<div class="<?php echo $classes; ?>">
<p><?php echo $notice; ?></p>
</div>
<?php
}
function states_places_colombia_init(){
load_plugin_textdomain('departamentos-y-ciudades-de-colombia-para-woocommerce',
FALSE, dirname(plugin_basename(__FILE__)) . '/languages');
if ( ! function_exists( 'is_plugin_active' ) ) require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
/**
* Check if WooCommerce is active
*/
if(is_plugin_active('woocommerce/woocommerce.php')) {
require_once ('includes/states-places.php');
/**
* Instantiate class
*/
$GLOBALS['wc_states_places'] = new WC_States_Places_Colombia(__FILE__);
require_once ('includes/filter-by-cities.php');
add_filter( 'woocommerce_shipping_methods', 'add_filters_by_cities_method' );
function add_filters_by_cities_method( $methods ) {
$methods['filters_by_cities_shipping_method'] = 'Filters_By_Cities_Method';
return $methods;
}
add_action( 'woocommerce_shipping_init', 'filters_by_cities_method' );
}
}
add_filter( 'woocommerce_default_address_fields', 'states_places_colombia_smp_woocommerce_default_address_fields', 1000, 1 );
function states_places_colombia_smp_woocommerce_default_address_fields( $fields ) {
if ($fields['city']['priority'] < $fields['state']['priority']){
$state_priority = $fields['state']['priority'];
$fields['state']['priority'] = $fields['city']['priority'];
$fields['city']['priority'] = $state_priority;
}
return $fields;
}