# tier-pricing-table/2.0.2/src/BackgroundProcessing/Updater/Updates/VersionAbstract.php

Tiered Pricing Table for WooCommerce, version 2.0.2. 75 lines.

- Page: https://pluginprobe.com/plugins/tier-pricing-table/2.0.2/code/src/BackgroundProcessing/Updater/Updates/VersionAbstract.php
- Raw: https://pluginprobe.com/plugins/tier-pricing-table/2.0.2/raw/src/BackgroundProcessing/Updater/Updates/VersionAbstract.php
- Modified: 2019-03-18T16:29:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tier-pricing-table/2.0.2/code/src/BackgroundProcessing/Updater/Updates/VersionAbstract.php#L10-L20`.

```php
<?php namespace TierPricingTable\BackgroundProcessing\Updater\Updates;

use TierPricingTable\BackgroundProcessing\BackgroundTask;
use TierPricingTable\BackgroundProcessing\Updater\Updater;

abstract class VersionAbstract extends BackgroundTask {

	protected $version;

	public function getVersion() {
		return $this->version;
	}

	protected function getIsCompletedUpdatingKey() {
		return 'tiered_price_table_completed_updating_' . $this->getVersion();
	}

	protected function getIsUpdatingKey() {
		return 'tiered_price_table_updating_' . $this->getVersion();
	}

	protected function isUpdating() {
		return get_option( $this->getIsUpdatingKey() ) == 'yes';
	}

	protected function isCompleted() {
		return get_option( $this->getIsCompletedUpdatingKey() ) == 'yes';
	}

	protected function begin() {
		if ( ! $this->isUpdating() && ! $this->isCompleted() ) {
			$this->push_to_queue( 'update_to_' . $this->getVersion() );

			update_option( $this->getIsUpdatingKey(), 'yes' );

			$this->save()->dispatch();
		}
	}

	protected function complete() {
		update_option( $this->getIsUpdatingKey(), 'no' );
		update_option( $this->getIsCompletedUpdatingKey(), 'yes' );

		$this->setCurrentDBVersion();
		$this->showCompleteUpdatingMessage();

		parent::complete();
	}

	protected function setCurrentDBVersion() {
		update_option( Updater::DB_OPTION, $this->getVersion() );
	}

	protected function showUpdatingMessage() {
		add_action( 'admin_notices', function () {
			?>
            <div class="notice notice-info">
                <p><?php _e( 'Tiered Pricing Table is updating database version. It may take a few minutes.',
						'tier-pricing-table' ) ?></p>
            </div>
			<?php
		} );
	}

	protected function showCompleteUpdatingMessage() {
		add_action( 'admin_notices', function () {
			?>
            <div class="notice notice-success">
                <p><?php _e( 'Tiered Pricing Table has been completed updating database version.',
						'tier-pricing-table' ) ?></p>
            </div>
			<?php
		} );
	}
}
```
