本文整理汇总了PHP中Magento\Framework\DataObject::getQty方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getQty方法的具体用法?PHP DataObject::getQty怎么用?PHP DataObject::getQty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getQty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAllItems
public function testGetAllItems()
{
$totals = $this->_prepareValidModelData();
$this->assertEquals([new \Magento\Framework\DataObject(['name' => $this->_validItem->getName(), 'qty' => $this->_validItem->getQty(), 'amount' => $this->_validItem->getPrice()])], $this->_model->getAllItems());
$this->assertEquals($totals['subtotal'], $this->_model->getSubtotal());
$this->assertEquals($totals['tax'], $this->_model->getTax());
$this->assertEquals($totals['shipping'], $this->_model->getShipping());
$this->assertEquals($totals['discount'], $this->_model->getDiscount());
}
示例2: init
/**
* @param \Magento\Quote\Model\Quote $quote
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Framework\DataObject $config
* @return \Magento\Quote\Model\Quote\Item|string
*/
public function init(\Magento\Quote\Model\Quote $quote, \Magento\Catalog\Model\Product $product, \Magento\Framework\DataObject $config)
{
$stockItem = $this->stockRegistry->getStockItem($product->getId(), $quote->getStore()->getWebsiteId());
if ($stockItem->getIsQtyDecimal()) {
$product->setIsQtyDecimal(1);
} else {
$config->setQty((int) $config->getQty());
}
$product->setCartQty($config->getQty());
$item = $quote->addProduct($product, $config, \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL);
return $item;
}
示例3: getItemQty
/**
* Get item qty
*
* @param \Magento\Framework\DataObject $item
* @return int
*/
public function getItemQty(\Magento\Framework\DataObject $item)
{
return $item->getQty() * 1 ? $item->getQty() * 1 : 1;
}
示例4: getPriceInclTax
/**
* Get sales item (quote item, order item etc) price including tax based on row total and tax amount
*
* @param \Magento\Framework\DataObject $item
* @return float
*/
public function getPriceInclTax($item)
{
if ($item->getPriceInclTax()) {
return $item->getPriceInclTax();
}
$qty = $item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1);
$taxAmount = $item->getTaxAmount() + $item->getDiscountTaxCompensation();
$price = floatval($qty) ? ($item->getRowTotal() + $taxAmount) / $qty : 0;
return $this->priceCurrency->round($price);
}