WC_Legacy_Cart::__get( string $name )
Magic getters.
Description Description
If you add/remove cases here please update $legacy_keys in __isset accordingly.
Parameters Parameters
- $name
-
(Required) Property name.
Return Return
(mixed)
Source Source
File: includes/legacy/class-wc-legacy-cart.php
public function &__get( $name ) {
$value = '';
switch ( $name ) {
case 'dp' :
$value = wc_get_price_decimals();
break;
case 'prices_include_tax' :
$value = wc_prices_include_tax();
break;
case 'round_at_subtotal' :
$value = 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' );
break;
case 'cart_contents_total' :
$value = $this->get_cart_contents_total();
break;
case 'total' :
$value = $this->get_total( 'edit' );
break;
case 'subtotal' :
$value = $this->get_subtotal() + $this->get_subtotal_tax();
break;
case 'subtotal_ex_tax' :
$value = $this->get_subtotal();
break;
case 'tax_total' :
$value = $this->get_fee_tax() + $this->get_cart_contents_tax();
break;
case 'fee_total' :
$value = $this->get_fee_total();
break;
case 'discount_cart' :
$value = $this->get_discount_total();
break;
case 'discount_cart_tax' :
$value = $this->get_discount_tax();
break;
case 'shipping_total' :
$value = $this->get_shipping_total();
break;
case 'shipping_tax_total' :
$value = $this->get_shipping_tax();
break;
case 'display_totals_ex_tax' :
case 'display_cart_ex_tax' :
$value = ! $this->display_prices_including_tax();
break;
case 'cart_contents_weight' :
$value = $this->get_cart_contents_weight();
break;
case 'cart_contents_count' :
$value = $this->get_cart_contents_count();
break;
case 'coupons' :
$value = $this->get_coupons();
break;
// Arrays returned by reference to allow modification without notices. TODO: Remove in 4.0.
case 'taxes' :
wc_deprecated_function( 'WC_Cart->taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_cart_contents_taxes()', 'WC_Cart::set_cart_contents_taxes()' ) );
$value = &$this->totals[ 'cart_contents_taxes' ];
break;
case 'shipping_taxes' :
wc_deprecated_function( 'WC_Cart->shipping_taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_shipping_taxes()', 'WC_Cart::set_shipping_taxes()' ) );
$value = &$this->totals[ 'shipping_taxes' ];
break;
case 'coupon_discount_amounts' :
$value = &$this->coupon_discount_totals;
break;
case 'coupon_discount_tax_amounts' :
$value = &$this->coupon_discount_tax_totals;
break;
case 'fees' :
wc_deprecated_function( 'WC_Cart->fees', '3.2', sprintf( 'the fees API (%s)', 'WC_Cart::get_fees' ) );
// Grab fees from the new API.
$new_fees = $this->fees_api()->get_fees();
// Add new fees to the legacy prop so it can be adjusted via legacy property.
$this->fees = $new_fees;
// Return by reference.
$value = &$this->fees;
break;
// Deprecated args. TODO: Remove in 4.0.
case 'tax' :
wc_deprecated_argument( 'WC_Cart->tax', '2.3', 'Use WC_Tax directly' );
$this->tax = new WC_Tax();
$value = $this->tax;
break;
case 'discount_total':
wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' );
$value = 0;
break;
}
return $value;
}