コード例 #1
0
 public function test_bump_idb_version()
 {
     // should init with 1
     $this->assertEquals(1, WC_POS_Settings::bump_idb_version());
     // should increment version numbers
     $this->assertEquals(2, WC_POS_Settings::bump_idb_version());
 }
コード例 #2
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // this should only be init after woocommerce_init
     global $wp_actions;
     if (!isset($wp_actions['woocommerce_init'])) {
         return;
     }
     // common params
     $this->accounting = $this->accounting();
     $this->ajaxurl = admin_url('admin-ajax.php', 'relative');
     $this->customers = $this->customers();
     $this->debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG;
     $this->nonce = wp_create_nonce(WC_POS_PLUGIN_NAME);
     $this->wc_api = get_woocommerce_api_url('');
     $this->emulateHTTP = get_option('woocommerce_pos_emulateHTTP') === '1';
     $this->idbVersion = WC_POS_Settings::get_idb_version();
     // frontend params
     if (is_pos()) {
         $this->auto_print = wc_pos_get_option('checkout', 'auto_print_receipt');
         $this->denominations = WC_POS_i18n::currency_denominations();
         $this->discount_keys = wc_pos_get_option('general', 'discount_quick_keys');
         $this->hotkeys = wc_pos_get_option('hotkeys', 'hotkeys');
         $this->menu = $this->menu();
         $this->shipping = $this->shipping_labels();
         $this->store = array('name' => get_bloginfo('name'));
         $this->tabs = $this->product_tabs();
         $this->tax = $this->tax();
         $this->tax_classes = WC_POS_Tax::tax_classes();
         $this->tax_rates = WC_POS_Tax::tax_rates();
         $this->user = $this->user();
     }
     // admin params
     if (is_admin()) {
         $this->search_customers_nonce = wp_create_nonce('search-customers');
     }
 }
コード例 #3
0
 /**
  * Check version number, runs every admin page load
  */
 private function version_check()
 {
     $old = WC_POS_Settings::get_db_version();
     if (version_compare($old, WC_POS_VERSION, '<')) {
         WC_POS_Settings::bump_versions();
         $this->db_upgrade($old, WC_POS_VERSION);
     }
 }
コード例 #4
0
/**
 * @param $id
 * @param $key
 * @return bool
 */
function wc_pos_get_option($id, $key = false)
{
    $handlers = (array) WC_POS_Settings::handlers();
    if (!array_key_exists($id, $handlers)) {
        return false;
    }
    $settings = $handlers[$id]::get_instance();
    return $settings->get($key);
}