Skip to content

Commit

Permalink
Add update routine on activation
Browse files Browse the repository at this point in the history
  • Loading branch information
roykho committed May 2, 2016
1 parent 41c4edb commit 092eb87
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions includes/class-wc-geolocation-based-products-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function admin_settings_save() {
}

// update options
update_option( 'wc_geolocation_based_products_settings', $rows );
update_option( 'wc_geolocation_based_products_rules', $rows );
}

return true;
Expand All @@ -166,7 +166,7 @@ public function admin_settings_save() {
public function admin_settings_field() {
do_action( 'wc_geolocation_based_products_admin_save' );

$rows = get_option( 'wc_geolocation_based_products_settings', false );
$rows = get_option( 'wc_geolocation_based_products_rules', false );

$cats = $this->get_product_categories();
?>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-geolocation-based-products-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function get_matches() {

$products = array();

$rows = get_option( 'wc_geolocation_based_products_settings', false );
$rows = get_option( 'wc_geolocation_based_products_rules', false );

if ( $rows !== false ) {
// loop through the rows and get data
Expand Down
4 changes: 3 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Rules that are towards the bottom will supercede the rules above it. You can dra

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.

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.

== Frequently Asked Questions ==

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

= 1.5.0 =
* Add - Ability to show and hide products and categories by location. Since this is a major update, please empty out all rules and reapply.
* 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.

== Changelog ==

Expand Down
2 changes: 2 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
}

delete_option( 'wc_geolocation_based_products_settings' );
delete_option( 'wc_geolocation_based_products_rules' );
delete_option( 'wc_glbp_version' );
delete_option( 'wc_geolocation_based_products_test_country' );
wp_clear_scheduled_hook( 'wc_glbp_db_update' );
20 changes: 20 additions & 0 deletions woocommerce-geolocation-based-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@

if ( ! class_exists( 'WC_Geolocation_Based_Products' ) ) :

register_activation_hook( __FILE__, 'wc_glbp_activation' );

/**
* Activation tasks
*
* @since 1.5.0
* @version 1.5.0
* @return bool
*/
function wc_glbp_activation() {
// less than version 1.5.0
if ( ! get_option( 'wc_glbp_version' ) ) {
delete_option( 'wc_geolocation_based_products_settings' );

add_option( 'wc_glbp_version', '1.5.0', '', 'no' );
}

return true;
}

/**
* main class.
*
Expand Down

0 comments on commit 092eb87

Please sign in to comment.