instance_id = absint( $instance_id ); $this->id = self::METHOD_ID; $this->shipping_methods_option = 'flexible_shipping_methods_' . $this->instance_id; $this->shipping_method_order_option = 'flexible_shipping_method_order_' . $this->instance_id; $this->section_name = 'flexible_shipping'; $this->method_title = __( 'Flexible Shipping Group', 'flexible-shipping' ); $this->method_description = __( 'A group of Flexible Shipping methods - useful to organize numerous shipping methods.', 'flexible-shipping' ); $this->supports = array( 'instance-settings', ); if ( $this->is_allowed_support_shipping_zones() ) { $this->supports[] = 'shipping-zones'; } $this->instance_form_fields = array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'flexible-shipping' ), 'type' => 'checkbox', 'label' => __( 'Enable this shipment method', 'flexible-shipping' ), 'default' => 'yes', ), 'title' => array( 'title' => __( 'Shipping Title', 'flexible-shipping' ), 'type' => 'text', 'description' => __( 'This controls the title which the user sees during checkout.', 'flexible-shipping' ), 'default' => __( 'Flexible Shipping', 'flexible-shipping' ), 'desc_tip' => true ) ); if ( version_compare( WC()->version, '2.6' ) < 0 && $this->get_option( 'enabled', 'yes' ) == 'no' ) { $this->enabled = $this->get_option( 'enabled' ); } $this->title = $this->get_option( 'title' ); $this->init(); add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); } /** * Set logger. This logger is set by Flexible Shipping plugin. * * @param LoggerInterface $fs_logger . */ public static function set_fs_logger( LoggerInterface $fs_logger ) { static::$fs_logger = $fs_logger; } /** * @param MethodSettings $shipping_method_settings * * @return \WPDesk\FS\TableRate\Logger\ShippingMethodLogger */ private function prepare_shipping_method_calculation_logger( $shipping_method_settings ) { $method_debug_mode = $shipping_method_settings->get_debug_mode(); $shipping_method_title = $shipping_method_settings->get_title(); $shipping_method_url = admin_url( 'admin.php?page=wc-settings&tab=shipping&instance_id=' . sanitize_key( $this->instance_id ) . '&action=edit&method_id=' . sanitize_key( $shipping_method_settings->get_id() ) ); if ( null !== static::$fs_logger ) { $fs_logger = static::$fs_logger; } else { $fs_logger = NullLogger(); } return new ShippingMethodLogger( $fs_logger, new NoticeLogger( $shipping_method_title, $shipping_method_url, 'yes' === $method_debug_mode && current_user_can( 'manage_woocommerce' ) ) ); } /** * Init your settings * * @access public * @return void */ function init() { $this->instance_form_fields = include( 'settings/flexible-shipping.php' ); // Load the settings API $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings $this->init_settings(); // This is part of the settings API. Loads settings you previously init. // Define user set variables $this->title = $this->get_option( 'title' ); $this->tax_status = $this->get_option( 'tax_status' ); $this->availability = $this->get_option( 'availability' ); $this->type = $this->get_option( 'type', 'class' ); } /** * Initialise Settings Form Fields */ public function init_form_fields() { $this->form_fields = include( 'settings/flexible-shipping.php' ); $this->form_fields = $this->add_beacon_search_data_to_fields( $this->form_fields ); } public function generate_title_shipping_methods_html( $key, $data ) { $field = $this->get_field_key( $key ); $defaults = array( 'title' => '', 'class' => '' ); $data = wp_parse_args( $data, $defaults ); ob_start(); ?>