2012-01-31 18:13:32 +00:00
|
|
|
<?php
|
2014-09-20 19:44:32 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2015-06-16 10:37:58 +00:00
|
|
|
exit;
|
2014-09-20 19:44:32 +00:00
|
|
|
}
|
2013-02-20 17:14:46 +00:00
|
|
|
|
2012-01-31 18:13:32 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* International Delivery - Based on the Flat Rate Shipping Method.
|
2012-01-31 18:13:32 +00:00
|
|
|
*
|
2015-06-16 10:37:58 +00:00
|
|
|
* @class WC_Shipping_Flat_Rate
|
|
|
|
* @version 2.4.0
|
2012-08-14 22:43:48 +00:00
|
|
|
* @package WooCommerce/Classes/Shipping
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
2012-12-31 18:25:09 +00:00
|
|
|
class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
|
2012-08-14 22:43:48 +00:00
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Constructor.
|
2012-08-14 22:43:48 +00:00
|
|
|
*/
|
2014-04-07 09:07:13 +00:00
|
|
|
public function __construct() {
|
2015-06-16 10:37:58 +00:00
|
|
|
$this->id = 'international_delivery';
|
|
|
|
$this->method_title = __( 'International Flat Rate', 'woocommerce' );
|
|
|
|
$this->method_description = __( 'International Flat Rate Shipping lets you charge a fixed rate for shipping.', 'woocommerce' );
|
|
|
|
$this->init();
|
2012-04-13 11:16:24 +00:00
|
|
|
|
2012-12-15 11:53:32 +00:00
|
|
|
add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
|
2013-08-12 21:09:04 +00:00
|
|
|
}
|
2012-01-31 18:13:32 +00:00
|
|
|
|
2013-08-12 21:09:04 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Initialise settings form fields.
|
2013-08-12 21:09:04 +00:00
|
|
|
*/
|
2014-04-07 09:07:13 +00:00
|
|
|
public function init_form_fields() {
|
2015-06-16 10:37:58 +00:00
|
|
|
parent::init_form_fields();
|
|
|
|
$this->form_fields['availability'] = array(
|
|
|
|
'title' => __( 'Availability', 'woocommerce' ),
|
|
|
|
'type' => 'select',
|
|
|
|
'class' => 'wc-enhanced-select',
|
|
|
|
'description' => '',
|
|
|
|
'default' => 'including',
|
|
|
|
'options' => array(
|
|
|
|
'including' => __( 'Selected countries', 'woocommerce' ),
|
|
|
|
'excluding' => __( 'Excluding selected countries', 'woocommerce' ),
|
|
|
|
)
|
|
|
|
);
|
2013-08-12 21:09:04 +00:00
|
|
|
}
|
2012-01-31 18:13:32 +00:00
|
|
|
|
2013-08-12 21:09:04 +00:00
|
|
|
/**
|
|
|
|
* is_available function.
|
|
|
|
*
|
2015-06-16 10:37:58 +00:00
|
|
|
* @param array $package
|
2013-08-12 21:09:04 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2014-04-07 09:07:13 +00:00
|
|
|
public function is_available( $package ) {
|
|
|
|
if ( "no" === $this->enabled ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( 'including' === $this->availability ) {
|
|
|
|
if ( is_array( $this->countries ) && ! in_array( $package['destination']['country'], $this->countries ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-06 14:45:00 +00:00
|
|
|
if ( is_array( $this->countries ) && ( in_array( $package['destination']['country'], $this->countries ) || ! $package['destination']['country'] ) ) {
|
2014-04-07 09:07:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-05-06 08:34:25 +00:00
|
|
|
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true, $package );
|
2013-08-12 21:09:04 +00:00
|
|
|
}
|
2014-09-20 19:44:32 +00:00
|
|
|
}
|