本文整理汇总了PHP中Magento\Framework\Object::getQtyOrdered方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getQtyOrdered方法的具体用法?PHP Object::getQtyOrdered怎么用?PHP Object::getQtyOrdered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getQtyOrdered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerItemSale
/**
* Subtract ordered qty for product
*
* @param \Magento\Framework\Object $item
* @return $this
* @throws \Magento\Framework\Model\Exception
*/
public function registerItemSale(\Magento\Framework\Object $item)
{
$productId = $item->getProductId();
if (!$productId) {
throw new \Magento\Framework\Model\Exception(__('We cannot specify a product identifier for the order item.'));
}
/** @var Item $stockItem */
$stockItem = $this->_stockItemFactory->create()->loadByProduct($productId);
if ($this->stockItemService->isQty($this->getProductType($productId))) {
if ($item->getStoreId()) {
$stockItem->setStoreId($item->getStoreId());
}
if ($stockItem->checkQty($item->getQtyOrdered())) {
$stockItem->subtractQty($item->getQtyOrdered());
$stockItem->save();
}
}
return $this;
}
示例2: getPriceInclTax
/**
* Get sales item (quote item, order item etc) price including tax based on row total and tax amount
*
* @param \Magento\Framework\Object $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);
}
示例3: displayPriceInclTax
/**
* Retrieve include tax html formatted content
*
* @param \Magento\Framework\Object $item
* @return string
*/
public function displayPriceInclTax(\Magento\Framework\Object $item)
{
$qty = $item->getQtyOrdered() ? $item->getQtyOrdered() : ($item->getQty() ? $item->getQty() : 1);
$baseTax = $item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0);
$tax = $item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0);
$basePriceTax = 0;
$priceTax = 0;
if (floatval($qty)) {
$basePriceTax = $item->getBasePrice() + $baseTax / $qty;
$priceTax = $item->getPrice() + $tax / $qty;
}
return $this->displayPrices($this->getOrder()->getStore()->roundPrice($basePriceTax), $this->getOrder()->getStore()->roundPrice($priceTax));
}