Skip to content

Commit 092eb87

Browse files
committed
Add update routine on activation
1 parent 41c4edb commit 092eb87

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

includes/class-wc-geolocation-based-products-admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function admin_settings_save() {
150150
}
151151

152152
// update options
153-
update_option( 'wc_geolocation_based_products_settings', $rows );
153+
update_option( 'wc_geolocation_based_products_rules', $rows );
154154
}
155155

156156
return true;
@@ -166,7 +166,7 @@ public function admin_settings_save() {
166166
public function admin_settings_field() {
167167
do_action( 'wc_geolocation_based_products_admin_save' );
168168

169-
$rows = get_option( 'wc_geolocation_based_products_settings', false );
169+
$rows = get_option( 'wc_geolocation_based_products_rules', false );
170170

171171
$cats = $this->get_product_categories();
172172
?>

includes/class-wc-geolocation-based-products-frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function get_matches() {
115115

116116
$products = array();
117117

118-
$rows = get_option( 'wc_geolocation_based_products_settings', false );
118+
$rows = get_option( 'wc_geolocation_based_products_rules', false );
119119

120120
if ( $rows !== false ) {
121121
// loop through the rows and get data

readme.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Rules that are towards the bottom will supercede the rules above it. You can dra
5050

5151
You can test each individual rule by checking the "test" checkbox. This will simulate your current location to match what is set for that rule.
5252

53+
This plugin utilizes the MaxMind GeoIP API and thus will store a copy of the database on your site. This makes for a better experience for users. The API will download the database once a week to refresh any updated geolocation data.
54+
5355
== Frequently Asked Questions ==
5456

5557
= This plugin does not seem to working =
@@ -71,7 +73,7 @@ You can post a GitHub issue here https://github.com/roykho/woocommerce-geolocati
7173
== Upgrade Notice ==
7274

7375
= 1.5.0 =
74-
* Add - Ability to show and hide products and categories by location. Since this is a major update, please empty out all rules and reapply.
76+
* Add - Ability to show and hide products and categories by location. Since this is a major update, rules will be emptied. Please reapply all rules.
7577

7678
== Changelog ==
7779

uninstall.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
}
1010

1111
delete_option( 'wc_geolocation_based_products_settings' );
12+
delete_option( 'wc_geolocation_based_products_rules' );
13+
delete_option( 'wc_glbp_version' );
1214
delete_option( 'wc_geolocation_based_products_test_country' );
1315
wp_clear_scheduled_hook( 'wc_glbp_db_update' );

woocommerce-geolocation-based-products.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@
2121

2222
if ( ! class_exists( 'WC_Geolocation_Based_Products' ) ) :
2323

24+
register_activation_hook( __FILE__, 'wc_glbp_activation' );
25+
26+
/**
27+
* Activation tasks
28+
*
29+
* @since 1.5.0
30+
* @version 1.5.0
31+
* @return bool
32+
*/
33+
function wc_glbp_activation() {
34+
// less than version 1.5.0
35+
if ( ! get_option( 'wc_glbp_version' ) ) {
36+
delete_option( 'wc_geolocation_based_products_settings' );
37+
38+
add_option( 'wc_glbp_version', '1.5.0', '', 'no' );
39+
}
40+
41+
return true;
42+
}
43+
2444
/**
2545
* main class.
2646
*

0 commit comments

Comments
 (0)