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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 4 years ago admin 4 years ago blocks 5 years ago cli 4 years ago customizer 4 years ago data-stores 4 years ago emails 4 years ago export 4 years ago gateways 4 years ago import 4 years ago integrations 5 years ago interfaces 4 years ago legacy 5 years ago libraries 6 years ago log-handlers 5 years ago payment-tokens 5 years ago queue 5 years ago rest-api 4 years ago shipping 5 years ago shortcodes 5 years ago theme-support 4 years ago tracks 4 years ago traits 5 years ago walkers 5 years ago wccom-site 5 years ago widgets 4 years ago class-wc-ajax.php 4 years ago class-wc-api.php 5 years ago class-wc-auth.php 4 years ago class-wc-autoloader.php 5 years ago class-wc-background-emailer.php 5 years ago class-wc-background-updater.php 5 years ago class-wc-breadcrumb.php 5 years ago class-wc-cache-helper.php 4 years ago class-wc-cart-fees.php 5 years ago class-wc-cart-session.php 5 years ago class-wc-cart-totals.php 4 years ago class-wc-cart.php 4 years ago class-wc-checkout.php 4 years ago class-wc-cli.php 4 years ago class-wc-comments.php 4 years ago class-wc-countries.php 4 years ago class-wc-coupon.php 4 years ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 4 years ago class-wc-customer.php 4 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 6 years ago class-wc-datetime.php 5 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 4 years ago class-wc-download-handler.php 4 years ago class-wc-emails.php 5 years ago class-wc-embed.php 5 years ago class-wc-form-handler.php 5 years ago class-wc-frontend-scripts.php 4 years ago class-wc-geo-ip.php 5 years ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 4 years ago class-wc-https.php 4 years ago class-wc-install.php 4 years ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 5 years ago class-wc-logger.php 5 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 5 years ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 4 years ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 4 years ago class-wc-order-item-shipping.php 4 years ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 4 years ago class-wc-order-query.php 4 years ago class-wc-order-refund.php 5 years ago class-wc-order.php 4 years ago class-wc-payment-gateways.php 4 years ago class-wc-payment-tokens.php 5 years ago class-wc-post-data.php 4 years ago class-wc-post-types.php 4 years ago class-wc-privacy-background-process.php 5 years ago class-wc-privacy-erasers.php 4 years ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 4 years ago class-wc-product-attribute.php 4 years ago class-wc-product-download.php 4 years ago class-wc-product-external.php 5 years ago class-wc-product-factory.php 5 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 5 years ago class-wc-product-simple.php 5 years ago class-wc-product-variable.php 4 years ago class-wc-product-variation.php 4 years ago class-wc-query.php 4 years ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 5 years ago class-wc-regenerate-images.php 5 years ago class-wc-register-wp-admin-settings.php 4 years ago class-wc-rest-authentication.php 5 years ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 5 years ago class-wc-shipping-rate.php 4 years ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 5 years ago class-wc-shipping.php 4 years ago class-wc-shortcodes.php 5 years ago class-wc-structured-data.php 5 years ago class-wc-tax.php 5 years ago class-wc-template-loader.php 4 years ago class-wc-tracker.php 4 years ago class-wc-validation.php 5 years ago class-wc-webhook.php 5 years ago class-woocommerce.php 4 years ago wc-account-functions.php 5 years ago wc-attribute-functions.php 4 years ago wc-cart-functions.php 5 years ago wc-conditional-functions.php 4 years ago wc-core-functions.php 4 years ago wc-coupon-functions.php 5 years ago wc-deprecated-functions.php 4 years ago wc-formatting-functions.php 4 years ago wc-notice-functions.php 5 years ago wc-order-functions.php 4 years ago wc-order-item-functions.php 5 years ago wc-page-functions.php 5 years ago wc-product-functions.php 4 years ago wc-rest-functions.php 5 years ago wc-stock-functions.php 5 years ago wc-template-functions.php 4 years ago wc-template-hooks.php 5 years ago wc-term-functions.php 4 years ago wc-update-functions.php 4 years ago wc-user-functions.php 5 years ago wc-webhook-functions.php 5 years ago wc-widget-functions.php 5 years ago
class-wc-shipping-rate.php
256 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 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Shipping rate class.
15 */
16 class WC_Shipping_Rate {
17
18 /**
19 * Stores data for this rate.
20 *
21 * @since 3.2.0
22 * @var array
23 */
24 protected $data = array(
25 'id' => '',
26 'method_id' => '',
27 'instance_id' => 0,
28 'label' => '',
29 'cost' => 0,
30 'taxes' => array(),
31 );
32
33 /**
34 * Stores meta data for this rate.
35 *
36 * @since 2.6.0
37 * @var array
38 */
39 protected $meta_data = array();
40
41 /**
42 * Constructor.
43 *
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.
50 */
51 public function __construct( $id = '', $label = '', $cost = 0, $taxes = array(), $method_id = '', $instance_id = 0 ) {
52 $this->set_id( $id );
53 $this->set_label( $label );
54 $this->set_cost( $cost );
55 $this->set_taxes( $taxes );
56 $this->set_method_id( $method_id );
57 $this->set_instance_id( $instance_id );
58 }
59
60 /**
61 * Magic methods to support direct access to props.
62 *
63 * @since 3.2.0
64 * @param string $key Key.
65 * @return bool
66 */
67 public function __isset( $key ) {
68 if ( 'meta_data' === $key ) {
69 wc_doing_it_wrong( __FUNCTION__, __( 'Use `array_key_exists` to check for meta_data on WC_Shipping_Rate to get the correct result.', 'woocommerce' ), '6.0' );
70 }
71 return isset( $this->data[ $key ] );
72 }
73
74 /**
75 * Magic methods to support direct access to props.
76 *
77 * @since 3.2.0
78 * @param string $key Key.
79 * @return mixed
80 */
81 public function __get( $key ) {
82 if ( is_callable( array( $this, "get_{$key}" ) ) ) {
83 return $this->{"get_{$key}"}();
84 } elseif ( isset( $this->data[ $key ] ) ) {
85 return $this->data[ $key ];
86 } else {
87 return '';
88 }
89 }
90
91 /**
92 * Magic methods to support direct access to props.
93 *
94 * @since 3.2.0
95 * @param string $key Key.
96 * @param mixed $value Value.
97 */
98 public function __set( $key, $value ) {
99 if ( is_callable( array( $this, "set_{$key}" ) ) ) {
100 $this->{"set_{$key}"}( $value );
101 } else {
102 $this->data[ $key ] = $value;
103 }
104 }
105
106 /**
107 * Set ID for the rate. This is usually a combination of the method and instance IDs.
108 *
109 * @since 3.2.0
110 * @param string $id Shipping rate ID.
111 */
112 public function set_id( $id ) {
113 $this->data['id'] = (string) $id;
114 }
115
116 /**
117 * Set shipping method ID the rate belongs to.
118 *
119 * @since 3.2.0
120 * @param string $method_id Shipping method ID.
121 */
122 public function set_method_id( $method_id ) {
123 $this->data['method_id'] = (string) $method_id;
124 }
125
126 /**
127 * Set instance ID the rate belongs to.
128 *
129 * @since 3.2.0
130 * @param int $instance_id Instance ID.
131 */
132 public function set_instance_id( $instance_id ) {
133 $this->data['instance_id'] = absint( $instance_id );
134 }
135
136 /**
137 * Set rate label.
138 *
139 * @since 3.2.0
140 * @param string $label Shipping rate label.
141 */
142 public function set_label( $label ) {
143 $this->data['label'] = (string) $label;
144 }
145
146 /**
147 * Set rate cost.
148 *
149 * @todo 4.0 Prevent negative value being set. #19293
150 * @since 3.2.0
151 * @param string $cost Shipping rate cost.
152 */
153 public function set_cost( $cost ) {
154 $this->data['cost'] = $cost;
155 }
156
157 /**
158 * Set rate taxes.
159 *
160 * @since 3.2.0
161 * @param array $taxes List of taxes applied to shipping rate.
162 */
163 public function set_taxes( $taxes ) {
164 $this->data['taxes'] = ! empty( $taxes ) && is_array( $taxes ) ? $taxes : array();
165 }
166
167 /**
168 * Get ID for the rate. This is usually a combination of the method and instance IDs.
169 *
170 * @since 3.2.0
171 * @return string
172 */
173 public function get_id() {
174 return apply_filters( 'woocommerce_shipping_rate_id', $this->data['id'], $this );
175 }
176
177 /**
178 * Get shipping method ID the rate belongs to.
179 *
180 * @since 3.2.0
181 * @return string
182 */
183 public function get_method_id() {
184 return apply_filters( 'woocommerce_shipping_rate_method_id', $this->data['method_id'], $this );
185 }
186
187 /**
188 * Get instance ID the rate belongs to.
189 *
190 * @since 3.2.0
191 * @return int
192 */
193 public function get_instance_id() {
194 return apply_filters( 'woocommerce_shipping_rate_instance_id', $this->data['instance_id'], $this );
195 }
196
197 /**
198 * Get rate label.
199 *
200 * @return string
201 */
202 public function get_label() {
203 return apply_filters( 'woocommerce_shipping_rate_label', $this->data['label'], $this );
204 }
205
206 /**
207 * Get rate cost.
208 *
209 * @since 3.2.0
210 * @return string
211 */
212 public function get_cost() {
213 return apply_filters( 'woocommerce_shipping_rate_cost', $this->data['cost'], $this );
214 }
215
216 /**
217 * Get rate taxes.
218 *
219 * @since 3.2.0
220 * @return array
221 */
222 public function get_taxes() {
223 return apply_filters( 'woocommerce_shipping_rate_taxes', $this->data['taxes'], $this );
224 }
225
226 /**
227 * Get shipping tax.
228 *
229 * @return array
230 */
231 public function get_shipping_tax() {
232 return apply_filters( 'woocommerce_get_shipping_tax', count( $this->taxes ) > 0 && ! WC()->customer->get_is_vat_exempt() ? array_sum( $this->taxes ) : 0, $this );
233 }
234
235 /**
236 * Add some meta data for this rate.
237 *
238 * @since 2.6.0
239 * @param string $key Key.
240 * @param string $value Value.
241 */
242 public function add_meta_data( $key, $value ) {
243 $this->meta_data[ wc_clean( $key ) ] = wc_clean( $value );
244 }
245
246 /**
247 * Get all meta data for this rate.
248 *
249 * @since 2.6.0
250 * @return array
251 */
252 public function get_meta_data() {
253 return $this->meta_data;
254 }
255 }
256