WC_Cart_Totals::get_shipping_from_cart()

Get shipping methods from the cart and normalise.


Description Description


Source Source

File: includes/class-wc-cart-totals.php

	protected function get_shipping_from_cart() {
		$this->shipping = array();

		if ( ! $this->cart->show_shipping() ) {
			return;
		}

		foreach ( $this->cart->calculate_shipping() as $key => $shipping_object ) {
			$shipping_line            = $this->get_default_shipping_props();
			$shipping_line->object    = $shipping_object;
			$shipping_line->tax_class = get_option( 'woocommerce_shipping_tax_class' );
			$shipping_line->taxable   = true;
			$shipping_line->total     = wc_add_number_precision_deep( $shipping_object->cost );
			$shipping_line->taxes     = wc_add_number_precision_deep( $shipping_object->taxes, false );
			$shipping_line->total_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $shipping_line->taxes ) );

			$this->shipping[ $key ] = $shipping_line;
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.