|
1
|
|
|
<?php |
|
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
3
|
|
|
exit; |
|
4
|
|
|
} |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* International Delivery - Based on the Flat Rate Shipping Method. |
|
8
|
|
|
* |
|
9
|
|
|
* This class is here for backwards commpatility for methods existing before zones existed. |
|
10
|
|
|
* |
|
11
|
|
|
* @deprecated 2.6.0 |
|
12
|
|
|
* @version 2.4.0 |
|
13
|
|
|
* @package WooCommerce/Classes/Shipping |
|
14
|
|
|
* @author WooThemes |
|
15
|
|
|
*/ |
|
16
|
|
|
class WC_Shipping_Legacy_International_Delivery extends WC_Shipping_Legacy_Flat_Rate { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Constructor. |
|
20
|
|
|
*/ |
|
21
|
|
|
public function __construct() { |
|
22
|
|
|
$this->id = 'legacy_international_delivery'; |
|
23
|
|
|
$this->method_title = __( 'International Flat Rate (Legacy)', 'woocommerce' ); |
|
24
|
|
|
$this->method_description = sprintf( __( '<strong>This method is deprecated in 2.6.0 and will be removed in future versions - we recommend disabling it and instead setting up a new rate within your <a href="%s">Shipping Zones</a>.</strong>', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=shipping' ) ); |
|
25
|
|
|
$this->init(); |
|
26
|
|
|
|
|
27
|
|
|
add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Return the name of the option in the WP DB. |
|
32
|
|
|
* @since 2.6.0 |
|
33
|
|
|
* @return string |
|
34
|
|
|
*/ |
|
35
|
|
|
public function get_option_key() { |
|
36
|
|
|
return $this->plugin_id . 'international_delivery' . '_settings'; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Initialise settings form fields. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function init_form_fields() { |
|
43
|
|
|
parent::init_form_fields(); |
|
44
|
|
|
$this->form_fields['availability'] = array( |
|
45
|
|
|
'title' => __( 'Availability', 'woocommerce' ), |
|
46
|
|
|
'type' => 'select', |
|
47
|
|
|
'class' => 'wc-enhanced-select', |
|
48
|
|
|
'description' => '', |
|
49
|
|
|
'default' => 'including', |
|
50
|
|
|
'options' => array( |
|
51
|
|
|
'including' => __( 'Selected countries', 'woocommerce' ), |
|
52
|
|
|
'excluding' => __( 'Excluding selected countries', 'woocommerce' ), |
|
53
|
|
|
) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* is_available function. |
|
59
|
|
|
* |
|
60
|
|
|
* @param array $package |
|
61
|
|
|
* @return bool |
|
62
|
|
|
*/ |
|
63
|
|
|
public function is_available( $package ) { |
|
64
|
|
|
if ( "no" === $this->enabled ) { |
|
65
|
|
|
return false; |
|
66
|
|
|
} |
|
67
|
|
|
if ( 'including' === $this->availability ) { |
|
68
|
|
|
if ( is_array( $this->countries ) && ! in_array( $package['destination']['country'], $this->countries ) ) { |
|
69
|
|
|
return false; |
|
70
|
|
|
} |
|
71
|
|
|
} else { |
|
72
|
|
|
if ( is_array( $this->countries ) && ( in_array( $package['destination']['country'], $this->countries ) || ! $package['destination']['country'] ) ) { |
|
73
|
|
|
return false; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true, $package ); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|