Made shipping method slightly easier to extend, e..g to add additional flat rates
This commit is contained in:
parent
3e89e19298
commit
2f918828a2
|
@ -12,10 +12,19 @@
|
|||
class WC_Flat_Rate extends WC_Shipping_Method {
|
||||
|
||||
function __construct() {
|
||||
$this->id = 'flat_rate';
|
||||
$this->method_title = __('Flat rate', 'woocommerce');
|
||||
$this->id = 'flat_rate';
|
||||
$this->method_title = __('Flat rate', 'woocommerce');
|
||||
|
||||
// Load the form fields.
|
||||
$this->flat_rate_option = 'woocommerce_flat_rates';
|
||||
$this->admin_page_heading = __('Flat Rates', 'woocommerce');
|
||||
$this->admin_page_description = __('Flat rates let you define a standard rate per item, or per order.', 'woocommerce');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
// Load the settings.
|
||||
|
@ -31,16 +40,13 @@ class WC_Flat_Rate extends WC_Shipping_Method {
|
|||
$this->cost = $this->settings['cost'];
|
||||
$this->fee = $this->settings['fee'];
|
||||
|
||||
// Flat rates
|
||||
$this->flat_rate_option = 'woocommerce_flat_rates';
|
||||
$this->admin_page_heading = __('Flat Rates', 'woocommerce');
|
||||
$this->admin_page_description = __('Flat rates let you define a standard rate per item, or per order.', 'woocommerce');
|
||||
// Load Flat rates
|
||||
$this->get_flat_rates();
|
||||
|
||||
// Actions
|
||||
// Add Actions
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_admin_options'));
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_flat_rates'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise Gateway Settings Form Fields
|
||||
|
|
|
@ -14,7 +14,10 @@ class WC_Free_Shipping extends WC_Shipping_Method {
|
|||
function __construct() {
|
||||
$this->id = 'free_shipping';
|
||||
$this->method_title = __('Free shipping', 'woocommerce');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
|
@ -31,7 +34,7 @@ class WC_Free_Shipping extends WC_Shipping_Method {
|
|||
|
||||
// Actions
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_admin_options'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise Gateway Settings Form Fields
|
||||
|
|
|
@ -11,35 +11,18 @@
|
|||
*/
|
||||
class WC_International_Delivery extends WC_Flat_Rate {
|
||||
|
||||
function __construct() {
|
||||
$this->id = 'international_delivery';
|
||||
$this->method_title = __('International Delivery', 'woocommerce');
|
||||
var $id = 'international_delivery';
|
||||
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
// Load the settings.
|
||||
$this->init_settings();
|
||||
|
||||
// Define user set variables
|
||||
$this->enabled = $this->settings['enabled'];
|
||||
$this->title = $this->settings['title'];
|
||||
$this->availability = $this->settings['availability'];
|
||||
$this->countries = $this->settings['countries'];
|
||||
$this->type = $this->settings['type'];
|
||||
$this->tax_status = $this->settings['tax_status'];
|
||||
$this->cost = $this->settings['cost'];
|
||||
$this->fee = $this->settings['fee'];
|
||||
|
||||
// Flat rates
|
||||
$this->flat_rate_option = 'woocommerce_international_delivery_flat_rates';
|
||||
$this->admin_page_heading = __('International Delivery', 'woocommerce');
|
||||
$this->admin_page_description = __('International delivery based on flat rate shipping.', 'woocommerce');
|
||||
$this->get_flat_rates();
|
||||
|
||||
// Actions
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_admin_options'));
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_flat_rates'));
|
||||
function __construct() {
|
||||
|
||||
$this->id = 'international_delivery';
|
||||
$this->method_title = __('International Delivery', 'woocommerce');
|
||||
|
||||
$this->flat_rate_option = 'woocommerce_international_delivery_flat_rates';
|
||||
$this->admin_page_heading = __('International Delivery', 'woocommerce');
|
||||
$this->admin_page_description = __('International delivery based on flat rate shipping.', 'woocommerce');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,11 +11,14 @@
|
|||
*/
|
||||
|
||||
class WC_Local_Delivery extends WC_Shipping_Method {
|
||||
|
||||
|
||||
function __construct() {
|
||||
$this->id = 'local-delivery';
|
||||
$this->id = 'local-delivery';
|
||||
$this->method_title = __('Local Delivery', 'woocommerce');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
|
@ -29,10 +32,9 @@ class WC_Local_Delivery extends WC_Shipping_Method {
|
|||
$this->type = $this->settings['type'];
|
||||
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_admin_options'));
|
||||
|
||||
}
|
||||
|
||||
function calculate_shipping() {
|
||||
}
|
||||
|
||||
function calculate_shipping() {
|
||||
global $woocommerce;
|
||||
$_tax = new WC_Tax();
|
||||
if ($this->type=='free') $shipping_total = 0;
|
||||
|
|
|
@ -15,7 +15,10 @@ class WC_Local_Pickup extends WC_Shipping_Method {
|
|||
function __construct() {
|
||||
$this->id = 'local-pickup';
|
||||
$this->method_title = __('Local Pickup', 'woocommerce');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
|
@ -27,10 +30,9 @@ class WC_Local_Pickup extends WC_Shipping_Method {
|
|||
$this->title = $this->settings['title'];
|
||||
|
||||
add_action('woocommerce_update_options_shipping_methods', array(&$this, 'process_admin_options'));
|
||||
|
||||
}
|
||||
|
||||
function calculate_shipping() {
|
||||
}
|
||||
|
||||
function calculate_shipping() {
|
||||
global $woocommerce;
|
||||
$_tax = new WC_Tax();
|
||||
|
||||
|
|
Loading…
Reference in New Issue