本文整理匯總了PHP中Magento\Quote\Model\Quote\Item::setIsQtyDecimal方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::setIsQtyDecimal方法的具體用法?PHP Item::setIsQtyDecimal怎麽用?PHP Item::setIsQtyDecimal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote\Item
的用法示例。
在下文中一共展示了Item::setIsQtyDecimal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update quote item qty.
* Custom price is updated in case 'custom_price' value exists
*
* @param Item $item
* @param array $info
* @throws InvalidArgumentException
* @return Updater
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function update(Item $item, array $info)
{
if (!isset($info['qty'])) {
throw new InvalidArgumentException(__('The qty value is required to update quote item.'));
}
$itemQty = $info['qty'];
if ($item->getProduct()->getStockItem()) {
if (!$item->getProduct()->getStockItem()->getIsQtyDecimal()) {
$itemQty = (int) $info['qty'];
} else {
$item->setIsQtyDecimal(1);
}
}
$itemQty = $itemQty > 0 ? $itemQty : 1;
if (isset($info['custom_price'])) {
$this->setCustomPrice($info, $item);
} elseif ($item->hasData('custom_price')) {
$this->unsetCustomPrice($item);
}
if (empty($info['action']) || !empty($info['configured'])) {
$noDiscount = !isset($info['use_discount']);
$item->setQty($itemQty);
$item->setNoDiscount($noDiscount);
$item->getProduct()->setIsSuperMode(true);
$item->getProduct()->unsSkipCheckRequiredOption();
$item->checkData();
}
return $this;
}
示例2: initialize
/**
* Initialize stock item
*
* @param \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem
* @param \Magento\Quote\Model\Quote\Item $quoteItem
* @param int $qty
*
* @return \Magento\Framework\DataObject
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function initialize(\Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem, \Magento\Quote\Model\Quote\Item $quoteItem, $qty)
{
/**
* When we work with subitem
*/
if ($quoteItem->getParentItem()) {
$rowQty = $quoteItem->getParentItem()->getQty() * $qty;
/**
* we are using 0 because original qty was processed
*/
$qtyForCheck = $this->quoteItemQtyList->getQty($quoteItem->getProduct()->getId(), $quoteItem->getId(), $quoteItem->getQuoteId(), 0);
} else {
$increaseQty = $quoteItem->getQtyToAdd() ? $quoteItem->getQtyToAdd() : $qty;
$rowQty = $qty;
$qtyForCheck = $this->quoteItemQtyList->getQty($quoteItem->getProduct()->getId(), $quoteItem->getId(), $quoteItem->getQuoteId(), $increaseQty);
}
$productTypeCustomOption = $quoteItem->getProduct()->getCustomOption('product_type');
if ($productTypeCustomOption !== null) {
// Check if product related to current item is a part of product that represents product set
if ($this->typeConfig->isProductSet($productTypeCustomOption->getValue())) {
$stockItem->setIsChildItem(true);
}
}
$stockItem->setProductName($quoteItem->getProduct()->getName());
$result = $this->stockState->checkQuoteItemQty($quoteItem->getProduct()->getId(), $rowQty, $qtyForCheck, $qty, $quoteItem->getProduct()->getStore()->getWebsiteId());
if ($stockItem->hasIsChildItem()) {
$stockItem->unsIsChildItem();
}
if ($result->getItemIsQtyDecimal() !== null) {
$quoteItem->setIsQtyDecimal($result->getItemIsQtyDecimal());
if ($quoteItem->getParentItem()) {
$quoteItem->getParentItem()->setIsQtyDecimal($result->getItemIsQtyDecimal());
}
}
/**
* Just base (parent) item qty can be changed
* qty of child products are declared just during add process
* exception for updating also managed by product type
*/
if ($result->getHasQtyOptionUpdate() && (!$quoteItem->getParentItem() || $quoteItem->getParentItem()->getProduct()->getTypeInstance()->getForceChildItemQtyChanges($quoteItem->getParentItem()->getProduct()))) {
$quoteItem->setData('qty', $result->getOrigQty());
}
if ($result->getItemUseOldQty() !== null) {
$quoteItem->setUseOldQty($result->getItemUseOldQty());
}
if ($result->getMessage() !== null) {
$quoteItem->setMessage($result->getMessage());
}
if ($result->getItemBackorders() !== null) {
$quoteItem->setBackorders($result->getItemBackorders());
}
return $result;
}