instance_id = absint( $instance_id ); $this->id = self::METHOD_ID; $this->method_title = __( 'DHL', 'woocommerce-dhl' ); $this->method_description = __( 'Integracja WooCommerce z DHL. Zapoznaj się z instrukcją obsługi →', 'woocommerce-dhl' ); $this->enabled = 'yes'; $this->title = __( 'DHL', 'woocommerce-dhl' ); $this->settings['enabled'] = 'yes'; $this->init(); add_action( 'woocommerce_update_options_shipping_' . $this->id, [ $this, 'process_admin_options' ] ); } /** * Init your settings. * * @return void */ public function init() { // Load the settings API. $this->init_settings(); $this->init_form_fields(); // Define user set variables. $this->login = $this->get_option( 'login' ); $this->password = $this->get_option( 'password' ); $this->api_key = $this->get_option( 'api_key' ); $this->test_mode = $this->get_option( 'test_mode', 'no' ); $this->login_parcelshop = $this->get_option( 'login_parcelshop' ); $this->password_parcelshop = $this->get_option( 'password_parcelshop' ); $this->cost = $this->get_option( 'cost' ); $this->cost_cod = $this->get_option( 'cost_cod' ); } /** * @return WPDesk_WooCommerce_DHL_API */ public function get_api() { if ( ! $this->api ) { $this->api = new WPDesk_WooCommerce_DHL_API( $this->login, $this->password, $this->get_logger(), $this->test_mode === 'yes' ); } return $this->api; } /** * */ private function get_logger() { if ( $this->get_option( self::OPTION_LOGGING, 'no' ) === 'yes' ) { $logger = ( new \VendorDHL\WPDesk\Logger\WPDeskLoggerFactory() )->createWPDeskLogger(); } else { $logger = new \VendorDHL\Psr\Log\NullLogger(); } return $logger; } /** * @return WPDesk_WooCommerce_DHL_Parcelshop_API */ public function get_parcelshop_api() { if ( ! $this->parcelshop_api && ! empty( $this->login_parcelshop ) && ! empty( $this->password_parcelshop ) ) { $this->parcelshop_api = new WPDesk_WooCommerce_DHL_Parcelshop_API( $this->login_parcelshop, $this->password_parcelshop, $this->get_logger(), $this->test_mode === 'yes' ); } return $this->parcelshop_api; } /** * Initialise Settings Form Fields. */ public function init_form_fields() { $this->form_fields = include( 'settings-dhl.php' ); } /** * @param array $form_fields . * @param false $echo . * * @return void */ public function generate_settings_html( $form_fields = [], $echo = false ) { parent::generate_settings_html( $form_fields ); ?> get_api(); $api->clear_cache(); } } }