id = 'auspost'; $this->method_title = __('Australia Post','australian-post'); $this->title = __('Australia Post','australian-post'); $this->init_form_fields(); $this->init_settings(); $this->enabled = $this->get_option('enabled'); $this->title = $this->get_option('title'); $this->api_key = $this->get_option('api_key'); $this->shop_post_code = $this->get_option('shop_post_code'); $this->default_weight = $this->get_option('default_weight'); $this->default_width = $this->get_option('default_width'); $this->default_length = $this->get_option('default_length'); $this->default_height = $this->get_option('default_height'); $this->show_duration = $this->get_option( 'show_duration' ); $this->debug_mode = $this->get_option('debug_mode'); add_action('woocommerce_update_options_shipping_'.$this->id, array($this, 'process_admin_options')); } public function init_form_fields(){ $dimensions_unit = strtolower( get_option( 'woocommerce_dimension_unit' ) ); $weight_unit = strtolower( get_option( 'woocommerce_weight_unit' ) ); $this->form_fields = array( 'enabled' => array( 'title' => __('Enable/Disable', 'woocommerce'), 'type' => 'checkbox', 'label' => __('Enable Australia Post', 'woocommerce'), 'default' => 'no', ), 'title' => array( 'title' => __( 'Method Title', 'woocommerce' ), 'type' => 'text', 'description' => __( 'This controls the title', 'woocommerce' ), 'default' => __( 'Australia Post Shipping', 'woocommerce' ), 'desc_tip' => true, ), 'api_key' => array( 'title' => __( 'API Key', 'australian-post' ), 'type' => 'text', 'description' => __( 'Get your key from https://developers.auspost.com.au/apis/pacpcs-registration', 'australian-post' ), 'default' => $this->api_key ), 'shop_post_code' => array( 'title' => __( 'Shop Origin Post Code', 'australian-post' ), 'type' => 'text', 'description' => __( 'Enter your Shop postcode.', 'australian-post' ), 'default' => '2000', 'css' => 'width:100px;', ), 'default_weight' => array( 'title' => __( 'Default Package Weight', 'australian-post' ), 'type' => 'text', 'default' => '0.5', 'description' => __( $weight_unit , 'australian-post' ), 'css' => 'width:100px;', ), 'default_width' => array( 'title' => __( 'Default Package Width', 'australian-post' ), 'type' => 'text', 'default' => '5', 'description' => __( $dimensions_unit, 'australian-post' ), 'css' => 'width:100px;', ), 'default_height' => array( 'title' => __( 'Default Package Height', 'australian-post' ), 'type' => 'text', 'default' => '5', 'description' => __( $dimensions_unit, 'australian-post' ), 'css' => 'width:100px;', ), 'default_length' => array( 'title' => __( 'Default Package Length', 'australian-post' ), 'type' => 'text', 'default' => '10', 'description' => __( $dimensions_unit, 'australian-post' ), 'css' => 'width:100px;', ), 'debug_mode' => array( 'title' => __( 'Enable Debug Mode', 'woocommerce' ), 'type' => 'checkbox', 'label' => __( 'Enable ', 'woocommerce' ), 'default' => 'no', 'description' => __('If debug mode is enabled, the shipping method will be activated just for the administrator.'), ), 'show_duration' => array( 'title' => __( 'Delivery Time', 'woocommerce' ), 'type' => 'checkbox', 'label' => __( 'Enable ', 'woocommerce' ), 'default' => 'yes', 'description' => __( 'Show Delivery Time Estimation in the Checkout page.', 'woocommerce' ), ), ); } /** * Admin Panel Options * - Options for bits like 'title' and availability on a country-by-country basis * * @since 1.0.0 * @return void */ public function admin_options() { ?>
debug_mode == 'yes'): ?>