Extended by shipping methods to handle shipping calculations etc.
Author: WooThemes
Inheritance: extends WC_Settings_API
 /**
  * Get setting form fields for instances of this shipping method within zones.
  *
  * @return array
  */
 public function get_instance_form_fields()
 {
     if (is_admin()) {
         wc_enqueue_js("\n\t\t\t\tjQuery( function( \$ ) {\n\t\t\t\t\tfunction wcFreeShippingShowHideMinAmountField( el ) {\n\t\t\t\t\t\tvar form = \$( el ).closest( 'form' );\n\t\t\t\t\t\tvar minAmountField = \$( '#woocommerce_free_shipping_min_amount', form ).closest( 'tr' );\n\t\t\t\t\t\tif ( 'coupon' === \$( el ).val() || '' === \$( el ).val() ) {\n\t\t\t\t\t\t\tminAmountField.hide();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tminAmountField.show();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\$( document.body ).on( 'change', '#woocommerce_free_shipping_requires', function() {\n\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( this );\n\t\t\t\t\t});\n\n\t\t\t\t\t// Change while load.\n\t\t\t\t\t\$( '#woocommerce_free_shipping_requires' ).change();\n\t\t\t\t\t\$( document.body ).on( 'wc_backbone_modal_loaded', function( evt, target ) {\n\t\t\t\t\t\tif ( 'wc-modal-shipping-method-settings' === target ) {\n\t\t\t\t\t\t\twcFreeShippingShowHideMinAmountField( \$( '#wc-backbone-modal-dialog #woocommerce_free_shipping_requires', evt.currentTarget ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t});\n\t\t\t");
     }
     return parent::get_instance_form_fields();
 }
    public function admin_options()
    {
        // Check curentcy.
        if (get_woocommerce_currency() != "DKK") {
            echo '<div class="error">
				<p>' . sprintf(__('Send24 requires that the <a href="%s">currency</a> is set to Danish Krone (DKK).', 'woocommerce-shipping-usps'), admin_url('admin.php?page=wc-settings&tab=general')) . '</p>
			</div>';
        }
        // Save/Update key.
        if (empty($this->send24_settings)) {
            add_option('send24_settings', $this->settings);
        } else {
            update_option('send24_settings', $this->settings);
        }
        // Check keys and zip user.
        if ($_POST) {
            $this->check_key_and_zip($_POST['woocommerce_send24_shipping_c_key'], $_POST['woocommerce_send24_shipping_c_secret'], $_POST['woocommerce_send24_shipping_zip']);
        } else {
            $this->check_key_and_zip($this->send24_settings['c_key'], $this->send24_settings['c_secret'], $this->send24_settings['zip']);
        }
        // Show settings
        parent::admin_options();
        // Check and show service.
        if ($_POST) {
            if (!empty($_POST['woocommerce_send24_shipping_enabled_services'])) {
                echo $this->generate_services_html($_POST['woocommerce_send24_shipping_enabled_services']);
            } else {
                echo $this->generate_services_html('no');
            }
        } else {
            echo $this->generate_services_html($this->send24_settings['enabled_services']);
        }
    }
 /**
  * add notifications section on top of settings.
  */
 public function admin_options()
 {
     global $current_section;
     if ($current_section == 'flagship_wc_shipping_method') {
         $this->ctx->getComponent('\\FS\\Components\\Notifier')->view();
     }
     parent::admin_options();
 }
 /**
  * Process and redirect if disabled.
  */
 public function process_admin_options()
 {
     parent::process_admin_options();
     if ('no' === $this->settings['enabled']) {
         wp_redirect(admin_url('admin.php?page=wc-settings&tab=shipping&section=options'));
         exit;
     }
 }
 /**
  * Is this method available?
  *
  * @version 2.5.7
  * @since   2.5.7
  * @param   array $package
  * @return  bool
  */
 public function is_available($package)
 {
     $available = parent::is_available($package);
     if ($available) {
         $total_weight = WC()->cart->get_cart_contents_weight();
         if (0 != $this->min_weight && $total_weight < $this->min_weight) {
             $available = false;
         } elseif (0 != $this->max_weight && $total_weight > $this->max_weight) {
             $available = false;
         }
     }
     return $available;
 }
 protected function get_var($key, $empty_value = null)
 {
     $option = '';
     if (is_null($empty_value)) {
         $empty_value = $this->get_field_default($key);
     }
     if (is_bool($empty_value)) {
         $option = isset($this->settings[$key]) ? $this->settings[$key] == 'yes' ? true : false : $empty_value;
     } else {
         $option = parent::get_option($key, $empty_value);
     }
     return $option;
 }
 public function process_admin_options()
 {
     $success = parent::process_admin_options();
     if (isset($_POST['wc_autoship_price_shipping_rates']) && is_array($_POST['wc_autoship_price_shipping_rates'])) {
         $rates = array();
         foreach ($_POST['wc_autoship_price_shipping_rates'] as $rate) {
             if ($rate['min_subtotal'] !== '' && $rate['cost'] !== '') {
                 $rate['min_subtotal'] = floatval($rate['min_subtotal']);
                 $rate['cost'] = floatval($rate['cost']);
                 $rates[] = $rate;
             }
         }
         usort($rates, 'wc_autoship_price_shipping_compare_min_subtotal');
         update_option('wc_autoship_price_shipping_rates', $rates);
     } else {
         update_option('wc_autoship_price_shipping_rates', array());
     }
     return $success;
 }
Exemplo n.º 8
0
    public function generate_settings_html($form_fields = false)
    {
        if (empty(Printful_Integration::instance()->settings['printful_key'])) {
            ?>
                <tr><td colspan="2">
                       <div class="error below-h2" style="margin:0">
                        <p>
                            Please add Printful API key to the
                            <a href="<?php 
            echo admin_url('admin.php?page=wc-settings&tab=integration&section=printful');
            ?>
">Printful Integration settings section</a>
                            to enable rate calculation.
                        </p>
                        </div>
                </td></tr>
            <?php 
        }
        parent::generate_settings_html($form_fields);
    }
 public function get_instance_form_fields()
 {
     return parent::get_instance_form_fields();
 }
 public function get_description_html($data)
 {
     return parent::get_description_html($data) . @$data['html'];
 }
 /**
  * admin_options function.
  *
  * @access public
  * @return void
  */
 public function admin_options()
 {
     // Check users environment supports this method
     $this->environment_check();
     // Show settings
     parent::admin_options();
 }
    public function admin_options()
    {
        // Check users environment supports this method
        $this->environment_check();
        ?>
		<div class="wf-banner updated below-h2">
			<img class="scale-with-grid" src="http://www.wooforce.com/wp-content/uploads/2015/07/WooForce-Logo-Admin-Banner-Basic.png" alt="Wordpress / WooCommerce USPS, Canada Post Shipping | WooForce">
  			<p class="main"><strong>FedEx Premium version streamlines your complete shipping process and saves time</strong></p>
			<p>&nbsp;-&nbsp;Print shipping label with postage.<br>
			&nbsp;-&nbsp;Auto Shipment Tracking: It happens automatically while generating the label.<br>
			&nbsp;-&nbsp;Box packing.<br>
			&nbsp;-&nbsp;Enable/disable, edit the names of, and add handling costs to shipping services.<br>
			&nbsp;-&nbsp;Excellent Support for setting it up!</p>
			<p><a href="http://www.wooforce.com/product/fedex-woocommerce-shipping-with-print-label-plugin/" target="_blank" class="button button-primary">Upgrade to Premium Version</a> <a href="http://fedex.wooforce.com/wp-admin/admin.php?page=wc-settings&tab=shipping&section=wf_fedex_woocommerce_shipping_method" target="_blank" class="button">Live Demo</a></p>
		</div>
		<style>
		.wf-banner img {
			float: right;
			margin-left: 1em;
			padding: 15px 0
		}
		</style>
		<?php 
        // Show settings
        parent::admin_options();
    }
 public function process_admin_options()
 {
     parent::process_admin_options();
     // Process services table
     $services_field = $this->get_field_key('services2');
     $services_custom_prices_field = $services_field . '_custom_prices';
     $custom_prices = [];
     if (isset($_POST[$services_field])) {
         $checked_services = $_POST[$services_field];
         foreach ($checked_services as $key => $service) {
             if (isset($_POST[$services_custom_prices_field][$service])) {
                 $custom_prices[$service] = $_POST[$services_custom_prices_field][$service];
             }
         }
     }
     update_option($services_custom_prices_field, $custom_prices);
 }
Exemplo n.º 14
0
 /**
  * Process and save options.
  *
  * Processes, validates and sanitizes options on the shipping page.
  *
  * @since 1.0.8
  */
 public function process_admin_options()
 {
     parent::process_admin_options();
     if (isset($_POST['method_priority'])) {
         foreach ($_POST['method_priority'] as $rate_id => $priority) {
             update_post_meta(absint($rate_id), '_priority', absint($priority));
         }
     }
 }
 /**
  * we need to reinitialize the settings field data.
  * 
  * @return bool
  */
 public function process_admin_options()
 {
     $success = parent::process_admin_options();
     $this->init_instance_settings();
     return $success;
 }
 /**
  * Process admin options.
  */
 public function process_admin_options()
 {
     parent::process_admin_options();
     wc_table_rate_admin_shipping_rows_process($this->instance_id);
 }
Exemplo n.º 17
0
    /**
     * admin_options function.
     *
     * @access public
     * @return void
     */
    public function admin_options()
    {
        // Check users environment supports this method
        $this->environment_check();
        ?>
		<div class="wf-banner updated below-h2">
  			<p class="main">
			<ul>
				<li style='color:red;'><strong>Your Business is precious! Go Premium!</li></strong>
				<li><strong>WooForce UPS Premium version for WooCommerce streamlines your complete shipping process and saves time.</strong></li>
				<li><strong>- Timely compatibility updates and bug fixes.</strong ></li>
				<li><strong>- Premium Support:</strong> Faster and time bound response for support requests.</li>
				<li><strong>- Option to enable Daily Rates, which gives same rates as UPS calculator.</strong></li>
				<li><strong>- More Features:</strong> Label Printing with Postage, Automatic Shipment Tracking, Box Packing, Weight based Packing and Many More..</li>
			</ul>
			</p>
			<p><a href="http://www.wooforce.com/product/ups-woocommerce-shipping-with-print-label-plugin/" target="_blank" class="button button-primary">Upgrade to Premium Version</a> <a href="http://ups.wooforce.com/wp-admin/admin.php?page=wc-settings&tab=shipping&section=wf_shipping_ups" target="_blank" class="button">Live Demo</a></p>
		</div>
		<style>
		.wf-banner img {
			float: right;
			margin-left: 1em;
			padding: 15px 0
		}
		</style>
		<?php 
        // Show settings
        parent::admin_options();
    }