WC_Cart_Totals::get_shipping_from_cart
Get shipping methods from the cart and normalise.
Method of the class: WC_Cart_Totals{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->get_shipping_from_cart();
Changelog
| Since 3.2.0 | Introduced. |
WC_Cart_Totals::get_shipping_from_cart() WC Cart Totals::get shipping from cart code WC 10.4.3
protected function get_shipping_from_cart() {
$default_shipping_props = $this->get_default_shipping_props();
$this->shipping = array_map(
function ( $shipping_object ) use ( $default_shipping_props ) {
$shipping_line = clone $default_shipping_props;
$shipping_line->object = $shipping_object;
$shipping_line->tax_class = get_option( 'woocommerce_shipping_tax_class', 'inherit' );
$shipping_line->taxable = true;
$shipping_line->total = wc_add_number_precision_deep( $shipping_object->cost );
$shipping_line->taxes = array_map(
array( $this, 'round_item_subtotal' ),
wc_add_number_precision_deep( $shipping_object->taxes, false )
);
$shipping_line->total_tax = array_sum( $shipping_line->taxes );
return $shipping_line;
},
$this->cart->calculate_shipping()
);
}