/**
  * Constructor for your shipping class.
  */
 public function __construct()
 {
     // flagship app
     $this->ctx = \FS\Context\ApplicationContext::getInstance();
     $this->id = $this->ctx->getComponent('\\FS\\Components\\Settings')['FLAGSHIP_SHIPPING_PLUGIN_ID'];
     // Id for your shipping method. Should be uunique.
     $this->method_title = __('FlagShip Shipping', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     // Title shown in admin
     $this->method_description = __('Obtains real time shipping rates via FlagShip Shipping API', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     // Description shown in admin
     $this->title = __('FlagShip Shipping', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     // This can be added as an setting but for this example its forced.
     // flagship options
     $this->enabled = $this->get_option('enabled');
     $this->token = $this->get_option('token');
     $this->required_address = $this->get_option('shipping_cost_requires_address', 'no');
     // providers
     $this->ctx->getComponent('\\FS\\Components\\Shipping\\Command');
     $this->ctx->getComponent('\\FS\\Components\\Url');
     $this->init();
 }
 /**
  * Constructor for your shipping class.
  */
 public function __construct($instance_id = 0)
 {
     parent::__construct($instance_id);
     // FlagShip application context
     $this->ctx = \FS\Context\ApplicationContext::getInstance();
     $this->id = $this->ctx->getComponent('\\FS\\Components\\Settings')['FLAGSHIP_SHIPPING_PLUGIN_ID'];
     $this->method_title = __('FlagShip Shipping', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     $this->method_description = __('Obtains real time shipping rates via FlagShip Shipping API', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     $this->supports = array('shipping-zones', 'instance-settings', 'instance-settings-modal', 'settings');
     $this->title = __('FlagShip Shipping', FLAGSHIP_SHIPPING_TEXT_DOMAIN);
     // flagship options
     $this->enabled = $this->get_instance_option('enabled');
     // load components
     // $this->ctx
     //     ->getComponent('\\FS\\Components\\Hook\\HookManager')
     //     ->registerHook('\\FS\\Components\\Hook\\SettingsFilters');
     $this->ctx->getComponent('\\FS\\Components\\Shipping\\Command');
     $this->ctx->getComponent('\\FS\\Components\\Url');
     $this->ctx->getComponent('\\FS\\Components\\Options')->sync($this->instance_id);
     $this->isLegacy = \version_compare(WC()->version, '2.6', '<');
     $this->init_instance_settings();
     $this->init();
 }