1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
3
|
|
|
exit; |
4
|
|
|
} |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Legacy Cart. |
8
|
|
|
* |
9
|
|
|
* Legacy and deprecated functions are here to keep the WC_Cart class clean. |
10
|
|
|
* This class will be removed in future versions. |
11
|
|
|
* |
12
|
|
|
* @class WC_Legacy_Cart |
13
|
|
|
* @version 2.7.0 |
14
|
|
|
* @package WooCommerce/Classes |
15
|
|
|
* @category Class |
16
|
|
|
* @author WooThemes |
17
|
|
|
*/ |
18
|
|
|
abstract class WC_Legacy_Cart { |
19
|
|
|
/** |
20
|
|
|
* Handle unset props. |
21
|
|
|
* @param string $key |
22
|
|
|
* @return mixed |
23
|
|
|
*/ |
24
|
|
|
public function __get( $key ) { |
25
|
|
|
_doing_it_wrong( $key, 'Cart properties should not be accessed directly.', '2.7' ); |
26
|
|
|
|
27
|
|
|
switch ( $key ) { |
28
|
|
|
case 'subtotal' : |
29
|
|
|
return $this->totals->get_items_subtotal( true ); |
30
|
|
|
case 'subtotal_ex_tax' : |
31
|
|
|
return $this->totals->get_items_subtotal( false ); |
32
|
|
|
case 'taxes' : |
33
|
|
|
return $this->totals->get_tax_data(); |
34
|
|
|
case 'cart_contents_total' : |
35
|
|
|
return $this->totals->get_items_total( false ); |
36
|
|
|
case 'discount_cart' : |
37
|
|
|
return $this->totals->get_discount_total(); |
38
|
|
|
case 'discount_cart_tax' : |
39
|
|
|
return $this->totals->get_discount_total_tax(); |
40
|
|
|
case 'cart_contents' : |
41
|
|
|
return $this->get_cart(); |
|
|
|
|
42
|
|
|
case 'removed_cart_contents' : |
43
|
|
|
return $this->items->get_removed_items(); |
44
|
|
|
case 'tax_total' : |
45
|
|
|
return $this->totals->get_tax_total(); |
46
|
|
|
case 'shipping_tax_total': |
47
|
|
|
return $this->totals->get_shipping_tax_total(); |
48
|
|
|
case 'taxes' : |
49
|
|
|
return wc_list_pluck( $this->totals->get_taxes(), 'get_tax_total' ); |
50
|
|
|
case 'shipping_taxes' : |
51
|
|
|
return wc_list_pluck( $this->totals->get_taxes(), 'get_shipping_tax_total' ); |
52
|
|
|
case 'total' : |
53
|
|
|
return $this->totals->get_total(); |
54
|
|
|
case 'coupon_discount_amounts' : |
55
|
|
|
return wp_list_pluck( $this->totals->get_coupons(), 'total' ); |
56
|
|
|
case 'coupon_discount_tax_amounts' : |
57
|
|
|
return wp_list_pluck( $this->totals->get_coupons(), 'total_tax' ); |
58
|
|
|
case 'applied_coupons' : |
59
|
|
|
return array_keys( $this->get_coupons() ); |
|
|
|
|
60
|
|
|
case 'coupons' : |
61
|
|
|
return $this->get_coupons(); |
|
|
|
|
62
|
|
|
case 'shipping_total' : |
63
|
|
|
return WC()->shipping->shipping_total; |
64
|
|
|
case 'shipping_taxes' : |
65
|
|
|
return WC()->shipping->shipping_taxes; |
66
|
|
|
case 'cart_session_data' : |
67
|
|
|
return array( |
68
|
|
|
'cart_contents_total' => $this->cart_contents_total, |
69
|
|
|
'total' => $this->total, |
70
|
|
|
'subtotal' => $this->subtotal, |
71
|
|
|
'subtotal_ex_tax' => $this->subtotal_ex_tax, |
72
|
|
|
'tax_total' => $this->tax_total, |
73
|
|
|
'taxes' => $this->taxes, |
74
|
|
|
'shipping_taxes' => $this->shipping_taxes, |
75
|
|
|
'discount_cart' => $this->discount_cart, |
76
|
|
|
'discount_cart_tax' => $this->discount_cart_tax, |
77
|
|
|
'shipping_total' => $this->shipping_total, |
78
|
|
|
'shipping_tax_total' => $this->shipping_tax_total, |
79
|
|
|
'coupon_discount_amounts' => $this->coupon_discount_amounts, |
80
|
|
|
'coupon_discount_tax_amounts' => $this->coupon_discount_tax_amounts, |
81
|
|
|
'fee_total' => $this->fee_total, |
82
|
|
|
'fees' => $this->fees, |
83
|
|
|
); |
84
|
|
|
case 'coupon_applied_count' : |
85
|
|
|
return wp_list_pluck( $this->totals->get_coupons(), 'count' ); |
86
|
|
|
case 'fee_total' : |
87
|
|
|
return $this->totals->get_fees_total( false ); |
88
|
|
|
case 'shipping_total' : |
89
|
|
|
return $this->totals->get_shipping_total( false ); |
90
|
|
|
case 'shipping_tax_total' : |
91
|
|
|
return $this->totals->get_shipping_tax_total(); |
92
|
|
|
case 'prices_include_tax' : |
93
|
|
|
return wc_prices_include_tax(); |
94
|
|
|
break; |
|
|
|
|
95
|
|
|
case 'round_at_subtotal' : |
96
|
|
|
return 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ); |
97
|
|
|
break; |
|
|
|
|
98
|
|
|
case 'tax_display_cart' : |
99
|
|
|
return get_option( 'woocommerce_tax_display_cart' ); |
100
|
|
|
break; |
|
|
|
|
101
|
|
|
case 'dp' : |
102
|
|
|
return wc_get_price_decimals(); |
103
|
|
|
break; |
|
|
|
|
104
|
|
|
case 'display_totals_ex_tax' : |
105
|
|
|
case 'display_cart_ex_tax' : |
106
|
|
|
return $this->tax_display_cart === 'excl'; |
107
|
|
|
break; |
|
|
|
|
108
|
|
|
case 'cart_contents_weight' : |
109
|
|
|
return $this->get_cart_contents_weight(); |
|
|
|
|
110
|
|
|
break; |
|
|
|
|
111
|
|
|
case 'cart_contents_count' : |
112
|
|
|
return $this->get_cart_contents_count(); |
|
|
|
|
113
|
|
|
break; |
|
|
|
|
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @deprecated 2.7.0 |
119
|
|
|
*/ |
120
|
|
|
public function add_discount( $coupon_code ) { |
121
|
|
|
_deprecated_function( 'WC_Cart::add_discount', '2.7', 'WC_Cart::add_coupon' ); |
122
|
|
|
return $this->add_coupon( $coupon_code ); |
|
|
|
|
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @deprecated 2.7.0 |
127
|
|
|
*/ |
128
|
|
|
public function has_discount( $coupon_code = '' ) { |
129
|
|
|
_deprecated_function( 'WC_Cart::has_discount', '2.7', 'WC_Cart::has_coupon' ); |
130
|
|
|
return $this->has_coupon( $coupon_code ); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @deprecated 2.7.0 |
135
|
|
|
*/ |
136
|
|
|
public function get_applied_coupons() { |
137
|
|
|
_deprecated_function( 'WC_Cart::get_applied_coupons', '2.7', 'WC_Cart::get_coupons' ); |
138
|
|
|
return array_keys( $this->get_coupons() ); |
|
|
|
|
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @deprecated 2.7.0 |
143
|
|
|
*/ |
144
|
|
|
public function check_cart_coupons() { |
145
|
|
|
_deprecated_function( 'WC_Cart::check_cart_coupons', '2.7', 'WC_Cart_Coupons::check_coupons' ); |
146
|
|
|
$this->coupons->check_coupons(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @deprecated 2.7.0 |
151
|
|
|
*/ |
152
|
|
|
public function check_customer_coupons( $posted ) { |
153
|
|
|
_deprecated_function( 'WC_Cart::check_customer_coupons', '2.7', 'WC_Cart_Coupons::check_customer_restriction/check_customer_limits' ); |
154
|
|
|
$this->coupons->check_customer_restriction( $posted ); |
155
|
|
|
$this->coupons->check_customer_limits( $posted ); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @deprecated 2.7.0 |
160
|
|
|
*/ |
161
|
|
|
public function show_shipping() { |
162
|
|
|
_deprecated_function( 'WC_Cart::show_shipping', '2.7', 'wc_cart_show_shipping' ); |
163
|
|
|
return wc_cart_show_shipping(); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @deprecated 2.7.0 |
168
|
|
|
*/ |
169
|
|
|
public function calculate_fees() { |
170
|
|
|
_deprecated_function( 'WC_Cart::calculate_fees', '2.7', 'WC_Cart_Fees::calculate_fees' ); |
171
|
|
|
$this->fees->calculate_fees(); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Add a product to the cart. |
176
|
|
|
* @deprecated 2.7.0 |
177
|
|
|
* @param int $product_id contains the id of the product to add to the cart |
178
|
|
|
* @param int $quantity contains the quantity of the item to add |
179
|
|
|
* @param int $variation_id |
180
|
|
|
* @param array $variation attribute values |
181
|
|
|
* @param array $cart_item_data extra cart item data we want to pass into the item |
182
|
|
|
* @return string|bool $cart_item_key |
183
|
|
|
*/ |
184
|
|
|
public function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) { |
185
|
|
|
_deprecated_function( 'WC_Cart::add_to_cart', '2.7', 'wc_add_to_cart' ); |
186
|
|
|
|
187
|
|
|
// Map legacy args to new. |
188
|
|
|
if ( $variation_id ) { |
189
|
|
|
$product_id = $variation_id; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
if ( $variation ) { |
|
|
|
|
193
|
|
|
$cart_item_data['variation'] = $variation; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
return wc_add_to_cart( $product_id, $quantity, $cart_item_data ); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Get cart items quantities - merged so we can do accurate stock checks on items across multiple lines. |
201
|
|
|
* @return array |
202
|
|
|
*/ |
203
|
|
|
public function get_cart_item_quantities() { |
204
|
|
|
_deprecated_function( 'WC_Cart::get_cart_item_quantities', '2.7', 'wc_cart_item_quantities' ); |
205
|
|
|
return wc_cart_item_quantities(); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @deprecated 2.7.0 |
210
|
|
|
*/ |
211
|
|
|
public function check_cart_items() { |
212
|
|
|
_deprecated_function( 'WC_Cart::check_cart_items', '2.7', 'WC_Cart_Items::check_items' ); |
213
|
|
|
$this->items->check_items(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @deprecated 2.7.0 |
218
|
|
|
*/ |
219
|
|
|
public function check_cart_item_stock() { |
220
|
|
|
_doing_it_wrong( 'check_cart_item_stock', 'Should not be called directly.', '2.7' ); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @deprecated 2.7.0 |
225
|
|
|
*/ |
226
|
|
|
public function persistent_cart_update() { |
227
|
|
|
_doing_it_wrong( 'persistent_cart_destroy', 'Should not be called directly.', '2.7' ); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @deprecated 2.7.0 |
232
|
|
|
*/ |
233
|
|
|
public function persistent_cart_destroy() { |
234
|
|
|
_doing_it_wrong( 'persistent_cart_destroy', 'Should not be called directly.', '2.7' ); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Determines the value that the customer spent and the subtotal |
239
|
|
|
* displayed, used for things like coupon validation. |
240
|
|
|
* |
241
|
|
|
* Since the coupon lines are displayed based on the TAX DISPLAY value |
242
|
|
|
* of cart, this is used to determine the spend. |
243
|
|
|
* |
244
|
|
|
* If cart totals are shown including tax, use the subtotal. |
245
|
|
|
* If cart totals are shown excluding tax, use the subtotal ex tax |
246
|
|
|
* (tax is shown after coupons). |
247
|
|
|
* @deprecated 2.7.0 |
248
|
|
|
* @since 2.6.0 |
249
|
|
|
* @return string |
250
|
|
|
*/ |
251
|
|
|
public function get_displayed_subtotal() { |
252
|
|
|
_deprecated_function( 'get_displayed_subtotal', '2.7', 'wc_cart_subtotal_to_display' ); |
253
|
|
|
return wc_cart_subtotal_to_display(); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Get the product row price per item. |
258
|
|
|
* |
259
|
|
|
* @param WC_Product $product |
260
|
|
|
* @return string formatted price |
261
|
|
|
*/ |
262
|
|
|
public function get_product_price( $product ) { |
263
|
|
|
_deprecated_function( 'get_product_price', '2.7', 'wc_cart_product_price_html' ); |
264
|
|
|
return wc_cart_product_price_html( $product ); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Gets the sub total (after calculation). |
269
|
|
|
* @deprecated 2.7.0 |
270
|
|
|
* @param bool $compound whether to include compound taxes |
271
|
|
|
* @return string formatted price |
272
|
|
|
*/ |
273
|
|
|
public function get_cart_subtotal( $compound = false ) { |
|
|
|
|
274
|
|
|
_deprecated_function( 'get_cart_subtotal', '2.7', 'wc_cart_subtotal_html' ); |
275
|
|
|
return wc_cart_subtotal_html( false, false ); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* Get the product row subtotal. |
280
|
|
|
* |
281
|
|
|
* Gets the tax etc to avoid rounding issues. |
282
|
|
|
* |
283
|
|
|
* When on the checkout (review order), this will get the subtotal based on the customer's tax rate rather than the base rate. |
284
|
|
|
* |
285
|
|
|
* @param WC_Product $product |
286
|
|
|
* @param int $quantity |
287
|
|
|
* @return string formatted price |
288
|
|
|
*/ |
289
|
|
|
public function get_product_subtotal( $product, $quantity ) { |
290
|
|
|
_deprecated_function( 'get_product_subtotal', '2.7', 'wc_cart_product_price_html' ); |
291
|
|
|
return wc_cart_product_price_html( $product, $quantity ); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Gets the total discount amount. |
296
|
|
|
* @deprecated 2.7.0 in favor to get_cart_discount_total() |
297
|
|
|
*/ |
298
|
|
|
public function get_total_discount() { |
299
|
|
|
_deprecated_function( 'get_total_discount', '2.7', 'get_cart_discount_total' ); |
300
|
|
|
return wc_price( $this->get_cart_discount_total() ); |
|
|
|
|
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Gets the url to the cart page. |
305
|
|
|
* |
306
|
|
|
* @deprecated 2.5.0 in favor to wc_get_cart_url() |
307
|
|
|
* @return string url to page |
308
|
|
|
*/ |
309
|
|
|
public function get_cart_url() { |
310
|
|
|
_deprecated_function( 'get_cart_url', '2.5', 'wc_get_cart_url' ); |
311
|
|
|
return wc_get_cart_url(); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Gets the url to the checkout page. |
316
|
|
|
* |
317
|
|
|
* @deprecated 2.5.0 in favor to wc_get_checkout_url() |
318
|
|
|
* @return string url to page |
319
|
|
|
*/ |
320
|
|
|
public function get_checkout_url() { |
321
|
|
|
_deprecated_function( 'get_checkout_url', '2.5', 'wc_get_checkout_url' ); |
322
|
|
|
return wc_get_checkout_url(); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* Coupons enabled function. Filterable. |
327
|
|
|
* |
328
|
|
|
* @deprecated 2.5.0 in favor to wc_coupons_enabled() |
329
|
|
|
* @return bool |
330
|
|
|
*/ |
331
|
|
|
public function coupons_enabled() { |
332
|
|
|
_deprecated_function( 'coupons_enabled', '2.5', 'wc_coupons_enabled' ); |
333
|
|
|
return wc_coupons_enabled(); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Sees if we need a shipping address. |
338
|
|
|
* |
339
|
|
|
* @deprecated 2.5.0 in favor to wc_ship_to_billing_address_only() |
340
|
|
|
* @return bool |
341
|
|
|
*/ |
342
|
|
|
public function ship_to_billing_address_only() { |
343
|
|
|
_deprecated_function( 'ship_to_billing_address_only', '2.5', 'wc_ship_to_billing_address_only' ); |
344
|
|
|
return wc_ship_to_billing_address_only(); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @deprecated 2.7.0 |
349
|
|
|
*/ |
350
|
|
|
public function get_cross_sells() { |
351
|
|
|
_deprecated_function( 'WC_Cart::get_cross_sells', '2.7', 'wc_get_cart_cross_sells' ); |
352
|
|
|
wc_get_cart_cross_sells(); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @deprecated 2.7.0 |
357
|
|
|
*/ |
358
|
|
|
public function get_remove_url( $cart_item_key ) { |
359
|
|
|
_deprecated_function( 'WC_Cart::get_remove_url', '2.7', 'wc_get_cart_remove_url' ); |
360
|
|
|
return wc_get_cart_remove_url( $cart_item_key ); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @deprecated 2.7.0 |
365
|
|
|
*/ |
366
|
|
|
public function get_undo_url( $cart_item_key ) { |
367
|
|
|
_deprecated_function( 'WC_Cart::get_undo_url', '2.7', 'wc_get_cart_undo_url' ); |
368
|
|
|
return wc_get_cart_undo_url( $cart_item_key ); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @deprecated 2.7.0 |
373
|
|
|
*/ |
374
|
|
|
public function get_discounted_price( $values, $price, $add_totals = false ) { |
|
|
|
|
375
|
|
|
_deprecated_function( 'WC_Cart::get_undo_url', '2.7' ); |
376
|
|
|
return $price; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @deprecated 2.7.0 |
381
|
|
|
*/ |
382
|
|
|
public function get_item_data( $cart_item, $flat = false ) { |
|
|
|
|
383
|
|
|
_deprecated_function( 'WC_Cart::get_item_data', '2.7', 'wc_display_item_data' ); |
384
|
|
|
return wc_display_item_data( $cart_item, $flat = false ); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @deprecated 2.7.0 Unused method. |
389
|
|
|
*/ |
390
|
|
|
public function get_total_ex_tax() { |
391
|
|
|
_deprecated_function( 'WC_Cart::get_total_ex_tax', '2.7' ); |
392
|
|
|
return apply_filters( 'woocommerce_cart_total_ex_tax', wc_price( min( 0, $this->total - $this->tax_total - $this->shipping_tax_total ) ) ); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @deprecated 2.7.0 Unused method. |
397
|
|
|
*/ |
398
|
|
|
public function init() { |
399
|
|
|
_deprecated_function( 'WC_Cart::init', '2.7' ); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* @deprecated 2.7.0 Taxes are just not calculated when not needed, so no need to remove them. |
404
|
|
|
*/ |
405
|
|
|
public function remove_taxes() { |
406
|
|
|
_deprecated_function( 'WC_Cart::remove_taxes', '2.7' ); |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* @deprecated 2.7.0 |
411
|
|
|
*/ |
412
|
|
|
public function find_product_in_cart( $cart_id = false ) { |
413
|
|
|
_deprecated_function( 'WC_Cart::find_product_in_cart', '2.7', 'WC_Cart::get_item_by_key' ); |
414
|
|
|
if ( $cart_id !== false ) { |
415
|
|
|
if ( is_array( $this->cart_contents ) && isset( $this->cart_contents[ $cart_id ] ) ) { |
416
|
|
|
return $cart_id; |
417
|
|
|
} |
418
|
|
|
} |
419
|
|
|
return ''; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Generate a unique ID for the cart item being added. |
424
|
|
|
* @deprecated 2.7.0 |
425
|
|
|
* @param int $product_id - id of the product the key is being generated for |
426
|
|
|
* @param int $variation_id of the product the key is being generated for |
427
|
|
|
* @param array $variation data for the cart item |
428
|
|
|
* @param array $cart_item_data other cart item data passed which affects this items uniqueness in the cart |
429
|
|
|
* @return string cart item key |
430
|
|
|
*/ |
431
|
|
|
public function generate_cart_id( $product_id, $variation_id = 0, $variation = array(), $cart_item_data = array() ) { |
432
|
|
|
_deprecated_function( 'WC_Cart::generate_cart_id', '2.7', 'WC_Cart_Items::generate_key' ); |
433
|
|
|
return apply_filters( 'woocommerce_cart_id', md5( json_encode( array( $product_id, $variation_id, $variation, $cart_item_data ) ) ), $product_id, $variation_id, $variation, $cart_item_data ); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @deprecated 2.7.0 |
438
|
|
|
*/ |
439
|
|
|
public function check_cart_item_validity() { |
440
|
|
|
_deprecated_function( 'WC_Cart::check_cart_item_validity', '2.7', 'WC_Cart_Items::check_items' ); |
441
|
|
|
$this->items->check_items(); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @deprecated 2.7.0 Unused |
446
|
|
|
*/ |
447
|
|
|
public function get_cart_shipping_total() { |
448
|
|
|
_deprecated_function( 'WC_Cart::get_cart_shipping_total', '2.7' ); |
449
|
|
|
if ( isset( $this->shipping_total ) ) { |
450
|
|
|
if ( $this->shipping_total > 0 ) { |
451
|
|
|
|
452
|
|
|
// Display varies depending on settings |
453
|
|
|
if ( $this->tax_display_cart == 'excl' ) { |
454
|
|
|
|
455
|
|
|
$return = wc_price( $this->shipping_total ); |
456
|
|
|
|
457
|
|
View Code Duplication |
if ( $this->shipping_tax_total > 0 && wc_prices_include_tax() ) { |
|
|
|
|
458
|
|
|
$return .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>'; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
return $return; |
462
|
|
|
|
463
|
|
|
} else { |
464
|
|
|
|
465
|
|
|
$return = wc_price( $this->shipping_total + $this->shipping_tax_total ); |
466
|
|
|
|
467
|
|
View Code Duplication |
if ( $this->shipping_tax_total > 0 && ! wc_prices_include_tax() ) { |
|
|
|
|
468
|
|
|
$return .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>'; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
return $return; |
472
|
|
|
|
473
|
|
|
} |
474
|
|
|
} else { |
475
|
|
|
return __( 'Free!', 'woocommerce' ); |
476
|
|
|
} |
477
|
|
|
} |
478
|
|
|
return ''; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* @deprecated 2.7.0 Unused |
483
|
|
|
*/ |
484
|
|
|
public function get_tax_amount( $tax_rate_id ) { |
485
|
|
|
_deprecated_function( 'WC_Cart::get_tax_amount', '2.7', 'Obtain from WC_Cart::get_taxes' ); |
486
|
|
|
$taxes = $this->totals->get_taxes(); |
487
|
|
|
return isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ]->get_tax_total() : 0; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* @deprecated 2.7.0 Unused |
492
|
|
|
*/ |
493
|
|
|
public function get_shipping_tax_amount( $tax_rate_id ) { |
494
|
|
|
_deprecated_function( 'WC_Cart::get_shipping_tax_amount', '2.7', 'Obtain from WC_Cart::get_taxes' ); |
495
|
|
|
$taxes = $this->totals->get_taxes(); |
496
|
|
|
return isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ]->get_shipping_tax_total() : 0; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* @deprecated 2.7.0 Unused |
501
|
|
|
*/ |
502
|
|
|
public function get_cart_total() { |
503
|
|
|
_deprecated_function( 'WC_Cart::get_cart_total', '2.7' ); |
504
|
|
|
if ( ! wc_prices_include_tax() ) { |
505
|
|
|
$cart_contents_total = wc_price( $this->cart_contents_total ); |
506
|
|
|
} else { |
507
|
|
|
$cart_contents_total = wc_price( $this->cart_contents_total + $this->tax_total ); |
508
|
|
|
} |
509
|
|
|
return apply_filters( 'woocommerce_cart_contents_total', $cart_contents_total ); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* @deprecated 2.7.0 Unused |
514
|
|
|
*/ |
515
|
|
|
public function get_cart_tax() { |
516
|
|
|
_deprecated_function( 'WC_Cart::get_cart_tax', '2.7' ); |
517
|
|
|
$cart_total_tax = wc_round_tax_total( $this->tax_total + $this->shipping_tax_total ); |
518
|
|
|
return apply_filters( 'woocommerce_get_cart_tax', $cart_total_tax ? wc_price( $cart_total_tax ) : '' ); |
519
|
|
|
} |
520
|
|
|
} |
521
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.