当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::getQty方法代码示例

本文整理汇总了PHP中Magento\Framework\Object::getQty方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getQty方法的具体用法?PHP Object::getQty怎么用?PHP Object::getQty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Object的用法示例。


在下文中一共展示了Object::getQty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAllItems

 public function testGetAllItems()
 {
     $totals = $this->_prepareValidModelData();
     $this->assertEquals([new \Magento\Framework\Object(['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());
 }
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:CartTest.php

示例2: init

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Object $config
  * @return \Magento\Quote\Model\Quote\Item|string
  */
 public function init(\Magento\Quote\Model\Quote $quote, \Magento\Catalog\Model\Product $product, \Magento\Framework\Object $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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Initializer.php

示例3: init

 /**
  * @param \Magento\Sales\Model\Quote $quote
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Object $config
  * @return \Magento\Sales\Model\Quote\Item|string
  */
 public function init(\Magento\Sales\Model\Quote $quote, \Magento\Catalog\Model\Product $product, \Magento\Framework\Object $config)
 {
     /** @var \Magento\CatalogInventory\Service\V1\Data\StockItem $stockItemDo */
     $stockItemDo = $this->stockItemService->getStockItem($product->getId());
     if ($stockItemDo->getStockId() && $stockItemDo->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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Initializer.php

示例4: validate

 /**
  * Validate Product Rule Condition
  *
  * @param \Magento\Framework\Object $object
  * @return bool
  */
 public function validate(\Magento\Framework\Object $object)
 {
     //@todo reimplement this method when is fixed MAGETWO-5713
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $object->getProduct();
     if (!$product instanceof \Magento\Catalog\Model\Product) {
         $product = $this->_productFactory->create()->load($object->getProductId());
     }
     $product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal());
     return parent::validate($product);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:17,代码来源:Product.php

示例5: getItemQty

 /**
  * Get item qty
  *
  * @param \Magento\Framework\Object $item
  * @return int
  */
 public function getItemQty(\Magento\Framework\Object $item)
 {
     return $item->getQty() * 1 ? $item->getQty() * 1 : 1;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:10,代码来源:AbstractSidebar.php

示例6: 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);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:16,代码来源:Data.php

示例7: 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));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:19,代码来源:AbstractItems.php


注:本文中的Magento\Framework\Object::getQty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。