WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Cart_Totals::get_items_from_cart() protected WC 3.2.0

Handles a cart or order object passed in for calculation. Normalises data into the same format for use by this class.

Each item is made up of the following props, in addition to those returned by get_default_item_props() for totals.

  • key: An identifier for the item (cart item key or line item ID).
  • cart_item: For carts, the cart item from the cart which may include custom data.
  • quantity: The qty for this line.
  • price: The line price in cents.
  • product: The product object this cart item is for.

{} Это метод класса: WC_Cart_Totals{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_items_from_cart();

Список изменений

С версии 3.2.0 Введена.

Код WC_Cart_Totals::get_items_from_cart() WC 4.7.1

<?php
protected function get_items_from_cart() {
	$this->items = array();

	foreach ( $this->cart->get_cart() as $cart_item_key => $cart_item ) {
		$item                          = $this->get_default_item_props();
		$item->key                     = $cart_item_key;
		$item->object                  = $cart_item;
		$item->tax_class               = $cart_item['data']->get_tax_class();
		$item->taxable                 = 'taxable' === $cart_item['data']->get_tax_status();
		$item->price_includes_tax      = wc_prices_include_tax();
		$item->quantity                = $cart_item['quantity'];
		$item->price                   = wc_add_number_precision_deep( $cart_item['data']->get_price() * $cart_item['quantity'] );
		$item->product                 = $cart_item['data'];
		$item->tax_rates               = $this->get_item_tax_rates( $item );
		$this->items[ $cart_item_key ] = $item;
	}
}