Returns the item line for 1 product line.

This method may return child lines if there are options/variants.
These lines will be informative, their price will be 0.

@param array $item

@return array

@throws \Exception
354929
protected function getItemLine(array $item)
    {
        $result = array();

        // $product can be empty if the product has been deleted.
        $product = $this->getRegistry()->model_catalog_product->getProduct($item['product_id']);
        if (!empty($product)) {
            $this->addPropertySource('product', $product);
        }
        $this->addPropertySource('item', $item);

        $this->addProductInfo($result);

        // Get vat range info from item line.
        $productPriceEx = $item['price'];
        $productVat = $item['tax'];
        $vatInfo = $this->getVatRangeTags($productVat, $productPriceEx, $this->precision, $this->precision);

        // Try to look up the vat rate via product.
        $vatInfo += $this->getVatRateLookupMetadata($product['tax_class_id']);

        // Check for cost price and margin scheme.
        if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
            // Margin scheme:
            // - Do not put VAT on invoice: send price incl VAT as unitprice.
            // - But still send the VAT rate to Acumulus.
            $result[Tag::UnitPrice] = $productPriceEx + $productVat;
        } else {
            $result[Tag::UnitPrice] = $productPriceEx;
            $result[Meta::VatAmount] = $productVat;
        }
        $result[Tag::Quantity] = $item['quantity'];
        $result += $vatInfo;

        // Options (variants).
        $options = $this->getOrderModel()->getOrderOptions($item['order_id'], $item['order_product_id']);
        if (!empty($options)) {
            // Add options as children.
            $result[Meta::ChildrenLines] = array();
            $optionsVatInfo = $vatInfo;
            $optionsVatInfo[Meta::VatAmount] = 0;
            foreach ($options as $option) {
                $result[Meta::ChildrenLines][] = array(
                    Tag::Product => "{$option['name']}: {$option['value']}",
                    Tag::UnitPrice => 0,
                      // Table order_option does not have a quantity field, so
                      // composite products with multiple same sub product
                      // are apparently not covered. Take quantity from parent.
                    Tag::Quantity => $item['quantity'],
                  ) + $optionsVatInfo;
            }
        }
        $this->removePropertySource('product');
        $this->removePropertySource('item');

        return $result;
    }
216869
private function getValidProductPriceForItem($item, $currency)
    {
        $product = $item->getCalcProduct();
        $specialPriceValue = null;
        $bulkPriceValue = null;

        //get special price
        $specialPrice = $this->priceManager->getSpecialPriceForCurrency($product, $currency);
        if ($specialPrice) {
            $specialPriceValue = $specialPrice->getPrice();
        }

        //get bulk price
        $bulkPrice = $this->priceManager->getBulkPriceForCurrency($product, $item->getCalcQuantity(), $currency);
        if ($bulkPrice) {
            $bulkPriceValue = $bulkPrice->getPrice();
        }

        //take the smallest
        if(!empty($specialPriceValue) && !empty($bulkPriceValue)) {
            $priceValue = $specialPriceValue;
            if ($specialPriceValue > $bulkPriceValue) {
                $priceValue = $bulkPriceValue;
            }
        } elseif (!empty($specialPriceValue)) {
            $priceValue = $specialPriceValue;
        } else {
            $priceValue = $bulkPriceValue;
        }

        // no price set - return 0
        if (empty($priceValue)) {
            return 0;
        }

        return $priceValue;
    }
940291
public static function includeInArray($item, $array)
    {
        if (self::isItemOrderInvalid($item, $array)) {
            return array_merge($array, [$item['name'] => $item['content']]);
        }

        $count = 0;
        $last  = $array;
        $first = [];
        foreach ($array as $key => $value) {
            if ($count == $item['order']) {
                return array_merge($first, [$item['name'] => $item['content']], $last);
            }

            unset($last[$key]);
            $first[$key] = $value;

            $count++;
        }
    }
909362
protected function getQuoteType($item)
    {
        $bounds = $this->getConfigItemBounds($item);

        if (!$bounds[0] or !$bounds[1]) {
            return $this->defaultQuoteType;
        }

        $file = $this->getFileContents();
        $substr = substr($file, $bounds[0], $bounds[1] - $bounds[0] + 1);
        return substr_count($substr, '"') > substr_count($substr, "'") ? '"' : "'";
    }
808839
public function normalizeValue($item)
    {
        if (is_array($item)) {
            $normalized = [];

            foreach ($item as $key => $value) {
                $key = $this->recursive ? $this->normalizeKey($key) : $key;

                if (is_array($value)) {
                    $normalized[$key] = $this->normalizeValue($value);
                } elseif ($value instanceof \stdClass) {
                    $normalized[$key] = $this->normalizeValue(
                        Arr::convertFromStdClass($value)
                    );
                } else {
                    $normalized[$key] = $value;
                }
            }
        } elseif ($item instanceof \stdClass) {
            $normalized = $this->normalizeValue(
                Arr::convertFromStdClass($item)
            );
        } else {
            $normalized = $item;
        }

        return $normalized;
    }
274782
public function get($item)
    {
        $data = $this->getData();

        return empty($data->$item) ? null : $data->$item;
    }
426143
public static function point(array $item): string
    {
        if (empty($item['file'])) {
            $result = '[internal function]';
        } else {
            $result = $item['file'];
            if (!empty($item['line'])) {
                $result .= '('.$item['line'].')';
            }
        }
        return $result;
    }
240536
public function addItem($item) {
		if (is_object($item)) {
			$modelClass = $this->getModel();
			if (! $item instanceof $modelClass) {
				throw new Exception('Model must be an instance of "' . $modelClass . '"');
			}
			
			$item->setCollection($this);
			
			if ($this->_primary === null) {
				$this->_data[]   = &$item->getDataLinked();
				$this->_models[] = $item;
				
				end($this->_data);
				$this->_map[] = key($this->_data);
			} else {
				if (is_array($this->_primaryDefinition)) {
					$idParts = [];
					
					foreach ($this->_primaryDefinition as $primaryPart) {
						if (! isset($item->$primaryPart)) {
							throw new Exception('Primary part "' . $primaryPart . '" not found');
						}
						
						$idParts[] = $item->$primaryPart;
					}
					
					$id = $this->arrayHashFunction($idParts);
				} else {
					if (! isset($item->{$this->_primary})) {
						throw new Exception('Primary "' . $this->_primary . '" not found');
					}
					
					$id = $item->{$this->_primary};
				}
				
				$this->_map[]       = $id;
				$this->_data[$id]   = &$item->getDataLinked();
				$this->_models[$id] = $item;
			}
		} elseif (is_array($item)) {
			if ($this->_primary === null) {
				$this->_data[] = $item;
				
				end($this->_data);
				$this->_map[] = key($this->_data);
				
			} else {
				if (is_array($this->_primaryDefinition)) {
					$idParts = [];
					
					foreach ($this->_primaryDefinition as $primaryPart) {
						if (! isset($item[$primaryPart])) {
							throw new Exception('Primary part "' . $primaryPart . '" not found');
						}
						
						$idParts[] = $item->$primaryPart;
					}
					
					$id = $this->arrayHashFunction($idParts);
				} else {
					if (! isset($item[$this->_primary])) {
						throw new Exception('Primary "' . $this->_primary . '" not found');
					}
					
					$id = $item[$this->_primary];
				}
				
				$this->_map[]     = $id;
				$this->_data[$id] = $item;
			}
		} else {
			throw new Exception('Unknown type of item: "' . gettype($item) . '"');
		}
		
		return $this;
	}
631957
protected function getItemTotal($item)
    {
        return $item->getRowTotal() - $item->getDiscountAmount() + $item->getTaxAmount() + $item->getWeeeTaxAppliedRowAmount();
    }
14501
protected function getItemSku($item)
    {
        if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
            return $item->getProductOptionByCode('simple_sku');
        }
        return $item->getSku();
    }
1140434
public function getLineItemForProduct(Product $product)
    {
        foreach ($this->getLineItems() as $lineItem)
        {
            if ($lineItem->getProduct()->getId() == $product->getId())
            {
                return $lineItem;
            }
        }

        return $this->createLineItemForProduct($product);
    }
664332
public function getChildMenuItems(MenuItem $item)
    {
        $results = '';
        foreach ($item->getChilds() as $child) {
            if ($child->hidden()) {
                continue;
            }

            if ($child->hasSubMenu()) {
                $results .= $this->getMultiLevelDropdownWrapper($child);
            } elseif ($child->isHeader()) {
                $results .= $this->getHeaderWrapper($child);
            } elseif ($child->isDivider()) {
                $results .= $this->getDividerWrapper();
            } else {
                $results .= $this->getMenuWithoutDropdownWrapper($child);
            }
        }

        return $results;
    }
675216
public static function method(array $item): string
    {
        if (empty($item['function'])) {
            return '';
        }
        $method = $item['function'];
        if (!empty($item['class'])) {
            $type = (empty($item['type']) ? '->' : $item['type']);
            $class = $item['class'].$type;
        } else {
            $class = '';
        }
        $args = isset($item['args']) ? $item['args'] : [];
        foreach ($args as &$arg) {
            $arg = self::arg($arg);
        }
        unset($arg);
        return $class.$method.'('.implode(', ', $args).')';
    }
1089663
protected function itemToArray($item)
    {
        if (is_array($item)) {
            return $item;
        } elseif (method_exists($item, 'toArray')) {
            return $item->toArray();
        } elseif (method_exists($item, 'getArrayCopy')) {
            return $item->getArrayCopy();
        }

        throw new Exception\RuntimeException(sprintf(
            'Items as part of this DataSource, with type "%s" cannot be cast to an array',
            is_object($item) ? get_class($item) : gettype($item)
        ));
    }
298299
protected function getItemLine(stdClass $item)
    {
        $result = array();
        $this->addPropertySource('item', $item);

        $this->addProductInfo($result);

        $productPriceEx = (float) $item->product_discountedPriceWithoutTax;
        $productPriceInc = (float) $item->product_final_price;
        $productVat = (float) $item->product_tax;

        $calcRule = $this->getCalcRule('VatTax', $item->virtuemart_order_item_id);
        if (!empty($calcRule->calc_value)) {
            $vatInfo = array(
                Tag::VatRate => (float) $calcRule->calc_value,
                Meta::VatRateSource => static::VatRateSource_Exact,
                Meta::VatClassId => $calcRule->virtuemart_calc_id,
                Meta::VatClassName => $calcRule->calc_rule_name,
            );
        } else {
            $vatInfo = $this->getVatRangeTags($productVat, $productPriceEx, $this->precision, $this->precision);
        }

        // Check for cost price and margin scheme.
        if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
            // Margin scheme:
            // - Do not put VAT on invoice: send price incl VAT as unitprice.
            // - But still send the VAT rate to Acumulus.
            $result[Tag::UnitPrice] = $productPriceInc;
        } else {
            $result += array(
                Tag::UnitPrice => $productPriceEx,
                Meta::UnitPriceInc => $productPriceInc,
                Meta::VatAmount => $productVat,
            );
        }
        $result[Tag::Quantity] = $item->product_quantity;
        $result += $vatInfo;

        // Add variant info.
        $children = $this->getVariantLines($item, $result[Tag::Quantity], $vatInfo);
        if (!empty($children)) {
            $result[Meta::ChildrenLines] = $children;
        }

        $this->removePropertySource('item');

        return $result;
    }
280922
public function forItem(CartItem $item)
    {
        if (config('laracart.tax_item_before_discount')) {
            return $item->subTotal(false, false, false, true) * $this->value;
        }

        return $item->price * $this->value;
    }
512774
protected function getInvocation(array $item)
    {
        $invocation = '';

        if (isset($item['class']) && isset($item['type'])) {
            $invocation.= $item['class'].$item['type'];
        }

        $invocation.= $item['function'];
        $invocation.= '(';

        if (isset($item['args'])) {
            $args = [];

            foreach ($item['args'] as $arg) {
                $args[] = $this->varToString($arg);
            }

            $invocation.= implode(', ', $args);
        }

        $invocation.= ')';

        return $invocation;
    }