public function __construct() { global $woocommerce; $this->id = 'sups'; $this->method_title = 'UPS'; $this->units = $this->method_errors = $this->packages = array(); // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); $this->enabled = $this->get_var('enabled'); $this->title = $this->get_var('title'); $this->debug = $this->get_var('debug'); $this->availability = $this->get_var('availability'); $this->countries = $this->get_var('countries', array()); $this->origin_postalcode = $this->get_var('origin_postalcode'); $this->origin_country_state = $this->get_var('origin_country_state', esc_attr(get_option('woocommerce_default_country'))); $this->pickup = $this->get_var('pickup'); $this->access_license_number = $this->get_var('access_license_number'); $this->user_id = str_replace('&', '&', $this->get_var('user_id')); $this->password = str_replace('&', '&', $this->get_var('password')); $this->shipper_number = $this->get_var('shipper_number'); $this->negotiated = $this->get_var('negotiated'); $this->insurance = $this->get_var('insurance'); $this->residential = $this->get_var('residential'); $this->packing_method = $this->get_var('packing_method'); $this->fee = $this->get_var('fee'); $this->calculate_fee = $this->get_var('calculate_fee'); $this->shipping_methods = $this->get_var('shipping_methods', array()); $this->custom_methods = $this->get_var('custom_methods', array()); $this->addresses = $this->get_var('multiple_address', array()); $this->boxes = $this->get_var('boxes', array()); if (empty($this->addresses)) { $country_state = $this->get_country_state($this->origin_country_state); $this->addresses[] = array('title' => $this->title, 'origin_postalcode' => $this->origin_postalcode, 'origin_country_state' => $this->origin_country_state, 'origin_country' => $country_state['country'], 'origin_state' => $country_state['state'], 'enabled' => 1); } if (!empty($this->addresses)) { foreach ($this->addresses as $address) { if ($address['origin_country_state'] == 'PL') { $this->services["82"] = "Today Standard (Poland)"; $this->services["83"] = "Today Dedicated Courier (Poland)"; $this->services["84"] = "Today Intercity (Poland)"; $this->services["85"] = "Today Express (Poland)"; $this->services["86"] = "Today Express Saver (Poland)"; break; } } } foreach ($this->services as $method_key => $method_name) { if (!isset($this->custom_methods[$method_key])) { $this->custom_methods[$method_key] = array('name' => woocommerce_clean($method_name), 'price_ajustment' => '', 'regional_service_availability' => '', 'zip_service_availability' => '', 'enabled' => isset($this->settings['shipping_methods']) && array_search($method_key, $this->settings['shipping_methods']) !== false || !isset($this->settings['shipping_methods']) ? '1' : '0'); } } // Used for weight based packing only $this->max_weight = '150'; add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'clear_transients')); parent::__construct(); }
public function admin_options() { $this->environment_check(); parent::admin_options(); }