instance_id = absint( $instance_id ); $this->id = 'flexible_shipping'; $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', 'flexible-shipping' ); $this->method_description = __( 'Flexible Shipping', 'flexible-shipping' ); $this->supports = array( 'shipping-zones', 'instance-settings', ); $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(); //$this->method_title = $this->get_option( 'title' ); //add_action( 'woocommerce_sections_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); } /** * 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' ); } /** * @param unknown $key * @return string * * Dodane w WooCommerce 2.4 * Dodane w celu zachowania kompatybilności z WooCommerce 2.3 * Przetestowane na WooCommerce 2.3.9 */ public function get_field_key( $key ) { return $this->plugin_id . $this->id . '_' . $key; } 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(); ?>