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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-shipping-rate.php
woocommerce / includes Last commit date
abstracts 1 month ago admin 6 days ago blocks 11 months ago cli 1 month ago customizer 4 months ago data-stores 1 month ago emails 5 days ago export 1 year ago gateways 1 month ago import 3 months ago integrations 2 months ago interfaces 4 months ago legacy 4 months ago libraries 1 month ago log-handlers 1 year ago payment-tokens 5 years ago product-usage 1 year ago queue 4 months ago react-admin 1 month ago rest-api 1 month ago shipping 3 months ago shortcodes 1 month ago theme-support 2 years ago tracks 1 month ago traits 5 years ago walkers 5 years ago wccom-site 1 month ago widgets 2 months ago class-wc-ajax.php 1 month ago class-wc-auth.php 1 year ago class-wc-autoloader.php 9 months ago class-wc-background-emailer.php 2 months ago class-wc-background-updater.php 5 years ago class-wc-brands-brand-settings-manager.php 1 year ago class-wc-brands-coupons.php 1 year ago class-wc-brands.php 1 month ago class-wc-breadcrumb.php 4 months ago class-wc-cache-helper.php 1 month ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 3 months ago class-wc-cart-totals.php 11 months ago class-wc-cart.php 1 month ago class-wc-checkout.php 1 month ago class-wc-cli.php 10 months ago class-wc-comments.php 4 months ago class-wc-countries.php 2 months ago class-wc-coupon.php 2 months ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 1 year ago class-wc-customer.php 1 day ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 3 years ago class-wc-datetime.php 4 years ago class-wc-deprecated-action-hooks.php 2 years ago class-wc-deprecated-filter-hooks.php 3 months ago class-wc-discounts.php 11 months ago class-wc-download-handler.php 1 month ago class-wc-emails.php 1 month ago class-wc-embed.php 1 year ago class-wc-form-handler.php 3 months ago class-wc-frontend-scripts.php 2 months ago class-wc-geo-ip.php 9 months ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 2 months ago class-wc-https.php 3 years ago class-wc-install.php 6 days ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 2 years ago class-wc-logger.php 4 months ago class-wc-meta-data.php 1 month ago class-wc-order-factory.php 2 months ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 5 months ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 1 month ago class-wc-order-item-shipping.php 5 months ago class-wc-order-item-tax.php 1 month ago class-wc-order-item.php 1 month ago class-wc-order-query.php 1 month ago class-wc-order-refund.php 1 year ago class-wc-order.php 1 month ago class-wc-payment-gateways.php 1 month ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 2 months ago class-wc-post-types.php 1 month ago class-wc-privacy-background-process.php 1 year ago class-wc-privacy-erasers.php 10 months ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 1 year ago class-wc-product-attribute.php 4 months ago class-wc-product-download.php 4 months ago class-wc-product-external.php 1 year ago class-wc-product-factory.php 3 months ago class-wc-product-grouped.php 3 months ago class-wc-product-query.php 4 months ago class-wc-product-simple.php 11 months ago class-wc-product-variable.php 1 month ago class-wc-product-variation.php 1 month ago class-wc-query.php 1 month ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 3 years ago class-wc-regenerate-images.php 2 years ago class-wc-register-wp-admin-settings.php 5 years ago class-wc-rest-authentication.php 2 years ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 3 months ago class-wc-shipping-rate.php 1 year ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 7 months ago class-wc-shipping.php 2 months ago class-wc-shortcodes.php 1 year ago class-wc-structured-data.php 1 month ago class-wc-tax.php 2 months ago class-wc-template-loader.php 7 months ago class-wc-tracker.php 1 month ago class-wc-validation.php 2 years ago class-wc-webhook.php 1 month ago class-woocommerce.php 1 day ago wc-account-functions.php 1 month ago wc-attribute-functions.php 1 month ago wc-brands-functions.php 1 year ago wc-cart-functions.php 1 month ago wc-conditional-functions.php 11 months ago wc-core-functions.php 2 months ago wc-coupon-functions.php 5 months ago wc-deprecated-functions.php 1 month ago wc-formatting-functions.php 1 month ago wc-interactivity-api-functions.php 2 months ago wc-notice-functions.php 5 months ago wc-order-functions.php 1 month ago wc-order-item-functions.php 3 years ago wc-order-step-logger-functions.php 4 months ago wc-page-functions.php 1 month ago wc-product-functions.php 2 months ago wc-rest-functions.php 7 months ago wc-stock-functions.php 7 months ago wc-template-functions.php 1 month ago wc-template-hooks.php 10 months ago wc-term-functions.php 2 months ago wc-update-functions.php 6 days ago wc-user-functions.php 1 month ago wc-webhook-functions.php 1 month ago wc-widget-functions.php 5 years ago
class-wc-shipping-rate.php
413 lines
1 <?php
2 /**
3 * WooCommerce Shipping Rate
4 *
5 * Simple Class for storing rates.
6 *
7 * @package WooCommerce\Classes\Shipping
8 * @since 2.6.0
9 */
10
11 declare( strict_types=1 );
12
13 defined( 'ABSPATH' ) || exit;
14
15 use Automattic\WooCommerce\Enums\ProductTaxStatus;
16
17 /**
18 * Shipping rate class.
19 */
20 class WC_Shipping_Rate implements JsonSerializable {
21
22 /**
23 * Stores data for this rate.
24 *
25 * @since 9.2.0 Added description and delivery_time.
26 * @var array
27 */
28 protected $data = array(
29 'id' => '',
30 'method_id' => '',
31 'instance_id' => 0,
32 'label' => '',
33 'cost' => 0,
34 'taxes' => array(),
35 'tax_status' => ProductTaxStatus::TAXABLE,
36 'description' => '',
37 'delivery_time' => '',
38 );
39
40 /**
41 * Stores meta data for this rate.
42 *
43 * @var array
44 */
45 protected $meta_data = array();
46
47 /**
48 * Constructor.
49 *
50 * @param string $id Shipping rate ID.
51 * @param string $label Shipping rate label.
52 * @param integer $cost Cost.
53 * @param array $taxes Taxes applied to shipping rate.
54 * @param string $method_id Shipping method ID.
55 * @param int $instance_id Shipping instance ID.
56 * @param string $tax_status Tax status.
57 * @param string $description Shipping rate description.
58 * @param string $delivery_time Shipping rate delivery time.
59 */
60 public function __construct( $id = '', $label = '', $cost = 0, $taxes = array(), $method_id = '', $instance_id = 0, $tax_status = ProductTaxStatus::TAXABLE, $description = '', $delivery_time = '' ) {
61 $this->set_id( $id );
62 $this->set_label( $label );
63 $this->set_cost( $cost );
64 $this->set_taxes( $taxes );
65 $this->set_method_id( $method_id );
66 $this->set_instance_id( $instance_id );
67 $this->set_tax_status( $tax_status );
68 $this->set_description( $description );
69 $this->set_delivery_time( $delivery_time );
70 }
71
72 /**
73 * Magic method to support direct access to data prop.
74 *
75 * @param string $key Key.
76 * @return bool
77 */
78 public function __isset( $key ) {
79 return isset( $this->data[ $key ] );
80 }
81
82 /**
83 * Magic methods to support direct access to props.
84 *
85 * @param string $key Key.
86 * @return mixed
87 */
88 public function __get( $key ) {
89 if ( is_callable( array( $this, "get_{$key}" ) ) ) {
90 return $this->{"get_{$key}"}();
91 }
92
93 if ( isset( $this->data[ $key ] ) ) {
94 return $this->data[ $key ];
95 }
96
97 return '';
98 }
99
100 /**
101 * Magic methods to support direct access to props.
102 *
103 * @since 3.2.0
104 * @param string $key Key.
105 * @param mixed $value Value.
106 */
107 public function __set( $key, $value ) {
108 if ( is_callable( array( $this, "set_{$key}" ) ) ) {
109 $this->{"set_{$key}"}( $value );
110 } else {
111 $this->data[ $key ] = $value;
112 }
113 }
114
115 /**
116 * When converted to JSON.
117 *
118 * @return object|array
119 */
120 #[\ReturnTypeWillChange]
121 public function jsonSerialize() {
122 return array(
123 'data' => $this->data,
124 'meta_data' => $this->meta_data,
125 );
126 }
127
128 /**
129 * Set ID for the rate. This is usually a combination of the method and instance IDs.
130 *
131 * @since 3.2.0
132 * @param string $id Shipping rate ID.
133 */
134 public function set_id( $id ) {
135 $this->data['id'] = (string) $id;
136 }
137
138 /**
139 * Set shipping method ID the rate belongs to.
140 *
141 * @since 3.2.0
142 * @param string $method_id Shipping method ID.
143 */
144 public function set_method_id( $method_id ) {
145 $this->data['method_id'] = (string) $method_id;
146 }
147
148 /**
149 * Set instance ID the rate belongs to.
150 *
151 * @since 3.2.0
152 * @param int $instance_id Instance ID.
153 */
154 public function set_instance_id( $instance_id ) {
155 $this->data['instance_id'] = absint( $instance_id );
156 }
157
158 /**
159 * Set rate label.
160 *
161 * @since 3.2.0
162 * @param string $label Shipping rate label.
163 */
164 public function set_label( $label ) {
165 $this->data['label'] = (string) $label;
166 }
167
168 /**
169 * Set rate cost.
170 *
171 * @todo 4.0 Prevent negative value being set. #19293
172 * @since 3.2.0
173 * @param string $cost Shipping rate cost.
174 */
175 public function set_cost( $cost ) {
176 $this->data['cost'] = $cost;
177 }
178
179 /**
180 * Set rate taxes.
181 *
182 * @since 3.2.0
183 * @param array $taxes List of taxes applied to shipping rate.
184 */
185 public function set_taxes( $taxes ) {
186 $this->data['taxes'] = ! empty( $taxes ) && is_array( $taxes ) ? $taxes : array();
187 }
188
189 /**
190 * Set tax status.
191 *
192 * @since 9.6.0
193 * @param string $value Tax status.
194 */
195 public function set_tax_status( $value ) {
196 if ( in_array( $value, array( ProductTaxStatus::TAXABLE, ProductTaxStatus::NONE ), true ) ) {
197 $this->data['tax_status'] = $value;
198 }
199 }
200
201 /**
202 * Set rate description.
203 *
204 * @since 9.2.0
205 * @param string $description Shipping rate description.
206 */
207 public function set_description( $description ) {
208 $this->data['description'] = (string) $description;
209 }
210
211 /**
212 * Set rate delivery time.
213 *
214 * @since 9.2.0
215 * @param string $delivery_time Shipping rate delivery time.
216 */
217 public function set_delivery_time( $delivery_time ) {
218 $this->data['delivery_time'] = (string) $delivery_time;
219 }
220
221 /**
222 * Get ID for the rate. This is usually a combination of the method and instance IDs.
223 *
224 * @since 3.2.0
225 * @return string
226 */
227 public function get_id() {
228 /**
229 * Filter the shipping rate ID.
230 *
231 * @since 3.2.0
232 * @param string $id The shipping rate ID.
233 * @param WC_Shipping_Rate $this The shipping rate object.
234 */
235 return apply_filters( 'woocommerce_shipping_rate_id', $this->data['id'], $this );
236 }
237
238 /**
239 * Get shipping method ID the rate belongs to.
240 *
241 * @since 3.2.0
242 * @return string
243 */
244 public function get_method_id() {
245 /**
246 * Filter the shipping method ID.
247 *
248 * @since 3.2.0
249 * @param string $method_id The shipping method ID.
250 * @param WC_Shipping_Rate $this The shipping rate object.
251 */
252 return apply_filters( 'woocommerce_shipping_rate_method_id', $this->data['method_id'], $this );
253 }
254
255 /**
256 * Get instance ID the rate belongs to.
257 *
258 * @since 3.2.0
259 * @return int
260 */
261 public function get_instance_id() {
262 /**
263 * Filter the shipping rate instance ID.
264 *
265 * @since 3.2.0
266 * @param int $instance_id The shipping rate instance ID.
267 * @param WC_Shipping_Rate $this The shipping rate object.
268 */
269 return apply_filters( 'woocommerce_shipping_rate_instance_id', $this->data['instance_id'], $this );
270 }
271
272 /**
273 * Get rate label.
274 *
275 * @return string
276 */
277 public function get_label() {
278 /**
279 * Filter the shipping rate label.
280 *
281 * @since 3.2.0
282 * @param string $label The shipping rate label.
283 * @param WC_Shipping_Rate $this The shipping rate object.
284 */
285 return apply_filters( 'woocommerce_shipping_rate_label', $this->data['label'], $this );
286 }
287
288 /**
289 * Get rate cost.
290 *
291 * @since 3.2.0
292 * @return string
293 */
294 public function get_cost() {
295 /**
296 * Filter the shipping rate cost.
297 *
298 * @since 3.2.0
299 * @param string $cost The shipping rate cost.
300 * @param WC_Shipping_Rate $this The shipping rate object.
301 */
302 return apply_filters( 'woocommerce_shipping_rate_cost', $this->data['cost'], $this );
303 }
304
305 /**
306 * Get rate taxes.
307 *
308 * @since 3.2.0
309 * @return array
310 */
311 public function get_taxes() {
312 /**
313 * Filter the shipping rate taxes.
314 *
315 * @since 3.2.0
316 * @param array $taxes The shipping rate taxes.
317 * @param WC_Shipping_Rate $this The shipping rate object.
318 */
319 return apply_filters( 'woocommerce_shipping_rate_taxes', $this->data['taxes'], $this );
320 }
321
322 /**
323 * Get shipping tax.
324 *
325 * @return float
326 */
327 public function get_shipping_tax() {
328 $taxes = $this->get_taxes();
329
330 /**
331 * Filter the shipping rate taxes.
332 *
333 * @since 3.2.0
334 * @param array $taxes The shipping rate taxes.
335 * @param WC_Shipping_Rate $this The shipping rate object.
336 */
337 return apply_filters( 'woocommerce_get_shipping_tax', count( $taxes ) > 0 && ! WC()->customer->get_is_vat_exempt() ? (float) array_sum( $taxes ) : 0.0, $this );
338 }
339
340 /**
341 * Get tax status.
342 *
343 * @return string
344 */
345 public function get_tax_status() {
346 /**
347 * Filter to allow tax status to be overridden for a shipping rate.
348 *
349 * @since 9.9.0
350 * @param string $tax_status Tax status.
351 * @param WC_Shipping_Rate $this Shipping rate object.
352 */
353 return apply_filters( 'woocommerce_shipping_rate_tax_status', $this->data['tax_status'], $this );
354 }
355
356 /**
357 * Get rate description.
358 *
359 * @since 9.2.0
360 * @return string
361 */
362 public function get_description() {
363 /**
364 * Filter the shipping rate description.
365 *
366 * @since 9.2.0
367 *
368 * @param string $description The current description.
369 * @param WC_Shipping_Rate $this The shipping rate.
370 */
371 return apply_filters( 'woocommerce_shipping_rate_description', $this->data['description'], $this );
372 }
373
374 /**
375 * Get rate delivery time.
376 *
377 * @since 9.2.0
378 * @return string
379 */
380 public function get_delivery_time() {
381 /**
382 * Filter the shipping rate delivery time.
383 *
384 * @since 9.2.0
385 *
386 * @param string $delivery_time The current description.
387 * @param WC_Shipping_Rate $this The shipping rate.
388 */
389 return apply_filters( 'woocommerce_shipping_rate_delivery_time', $this->data['delivery_time'], $this );
390 }
391
392 /**
393 * Add some meta data for this rate.
394 *
395 * @since 2.6.0
396 * @param string $key Key.
397 * @param string $value Value.
398 */
399 public function add_meta_data( $key, $value ) {
400 $this->meta_data[ wc_clean( $key ) ] = wc_clean( $value );
401 }
402
403 /**
404 * Get all meta data for this rate.
405 *
406 * @since 2.6.0
407 * @return array
408 */
409 public function get_meta_data() {
410 return $this->meta_data;
411 }
412 }
413