1
1
<?php
2
-
3
- if ( ! defined ( 'ABSPATH ' ) ) {
4
- exit ; // Exit if accessed directly
5
- }
6
-
7
2
/**
8
- * WooCommerce Shipping Rate Class.
3
+ * WooCommerce Shipping Rate
9
4
*
10
5
* Simple Class for storing rates.
11
6
*
12
- * @class WC_Shipping_Rate
13
- * @package WooCommerce/Classes/Shipping
14
- * @category Class
15
- * @author Automattic
7
+ * @package WooCommerce/Classes/Shipping
8
+ * @since 2.6.0
9
+ */
10
+
11
+ defined ( 'ABSPATH ' ) || exit;
12
+
13
+ /**
14
+ * Shipping rate class.
16
15
*/
17
16
class WC_Shipping_Rate {
18
17
@@ -42,12 +41,12 @@ class WC_Shipping_Rate {
42
41
/**
43
42
* Constructor.
44
43
*
45
- * @param string $id
46
- * @param string $label
47
- * @param integer $cost
48
- * @param array $taxes
49
- * @param string $method_id
50
- * @param int $instance_id
44
+ * @param string $id Shipping rate ID.
45
+ * @param string $label Shipping rate label.
46
+ * @param integer $cost Cost.
47
+ * @param array $taxes Taxes applied to shipping rate.
48
+ * @param string $method_id Shipping method ID.
49
+ * @param int $instance_id Shipping instance ID.
51
50
*/
52
51
public function __construct ( $ id = '' , $ label = '' , $ cost = 0 , $ taxes = array (), $ method_id = '' , $ instance_id = 0 ) {
53
52
$ this ->set_id ( $ id );
@@ -62,7 +61,7 @@ public function __construct( $id = '', $label = '', $cost = 0, $taxes = array(),
62
61
* Magic methods to support direct access to props.
63
62
*
64
63
* @since 3.2.0
65
- * @param string $key
64
+ * @param string $key Key.
66
65
* @return bool
67
66
*/
68
67
public function __isset ( $ key ) {
@@ -73,7 +72,7 @@ public function __isset( $key ) {
73
72
* Magic methods to support direct access to props.
74
73
*
75
74
* @since 3.2.0
76
- * @param string $key
75
+ * @param string $key Key.
77
76
* @return mixed
78
77
*/
79
78
public function __get ( $ key ) {
@@ -90,8 +89,8 @@ public function __get( $key ) {
90
89
* Magic methods to support direct access to props.
91
90
*
92
91
* @since 3.2.0
93
- * @param string $key
94
- * @param mixed $value
92
+ * @param string $key Key.
93
+ * @param mixed $value Value.
95
94
*/
96
95
public function __set ( $ key , $ value ) {
97
96
if ( is_callable ( array ( $ this , "set_ {$ key }" ) ) ) {
@@ -105,7 +104,7 @@ public function __set( $key, $value ) {
105
104
* Set ID for the rate. This is usually a combination of the method and instance IDs.
106
105
*
107
106
* @since 3.2.0
108
- * @param string $id
107
+ * @param string $id Shipping rate ID.
109
108
*/
110
109
public function set_id ( $ id ) {
111
110
$ this ->data ['id ' ] = (string ) $ id ;
@@ -115,7 +114,7 @@ public function set_id( $id ) {
115
114
* Set shipping method ID the rate belongs to.
116
115
*
117
116
* @since 3.2.0
118
- * @param string $method_id
117
+ * @param string $method_id Shipping method ID.
119
118
*/
120
119
public function set_method_id ( $ method_id ) {
121
120
$ this ->data ['method_id ' ] = (string ) $ method_id ;
@@ -125,7 +124,7 @@ public function set_method_id( $method_id ) {
125
124
* Set instance ID the rate belongs to.
126
125
*
127
126
* @since 3.2.0
128
- * @param int $instance_id
127
+ * @param int $instance_id Instance ID.
129
128
*/
130
129
public function set_instance_id ( $ instance_id ) {
131
130
$ this ->data ['instance_id ' ] = absint ( $ instance_id );
@@ -135,7 +134,7 @@ public function set_instance_id( $instance_id ) {
135
134
* Set rate label.
136
135
*
137
136
* @since 3.2.0
138
- * @param string $method_id
137
+ * @param string $label Shipping rate label.
139
138
*/
140
139
public function set_label ( $ label ) {
141
140
$ this ->data ['label ' ] = (string ) $ label ;
@@ -146,7 +145,7 @@ public function set_label( $label ) {
146
145
*
147
146
* @todo 4.0 Prevent negative value being set. #19293
148
147
* @since 3.2.0
149
- * @param string $cost
148
+ * @param string $cost Shipping rate cost.
150
149
*/
151
150
public function set_cost ( $ cost ) {
152
151
$ this ->data ['cost ' ] = $ cost ;
@@ -156,7 +155,7 @@ public function set_cost( $cost ) {
156
155
* Set rate taxes.
157
156
*
158
157
* @since 3.2.0
159
- * @param array $taxes
158
+ * @param array $taxes List of taxes applied to shipping rate.
160
159
*/
161
160
public function set_taxes ( $ taxes ) {
162
161
$ this ->data ['taxes ' ] = ! empty ( $ taxes ) && is_array ( $ taxes ) ? $ taxes : array ();
@@ -227,15 +226,15 @@ public function get_taxes() {
227
226
* @return array
228
227
*/
229
228
public function get_shipping_tax () {
230
- return apply_filters ( 'woocommerce_get_shipping_tax ' , sizeof ( $ this ->taxes ) > 0 && ! WC ()->customer ->get_is_vat_exempt () ? array_sum ( $ this ->taxes ) : 0 , $ this );
229
+ return apply_filters ( 'woocommerce_get_shipping_tax ' , count ( $ this ->taxes ) > 0 && ! WC ()->customer ->get_is_vat_exempt () ? array_sum ( $ this ->taxes ) : 0 , $ this );
231
230
}
232
231
233
232
/**
234
233
* Add some meta data for this rate.
235
234
*
236
235
* @since 2.6.0
237
- * @param string $key
238
- * @param string $value
236
+ * @param string $key Key.
237
+ * @param string $value Value.
239
238
*/
240
239
public function add_meta_data ( $ key , $ value ) {
241
240
$ this ->meta_data [ wc_clean ( $ key ) ] = wc_clean ( $ value );
0 commit comments