本文整理匯總了PHP中Magento\Quote\Model\Quote\Item::getId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getId方法的具體用法?PHP Item::getId怎麽用?PHP Item::getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote\Item
的用法示例。
在下文中一共展示了Item::getId方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getQtyForCheck
/**
* @param int $qty
* @return int
*/
public function getQtyForCheck($qty)
{
if (!$this->item->getParentItem()) {
$increaseQty = $this->item->getQtyToAdd() ? $this->item->getQtyToAdd() : $qty;
return $this->quoteItemQtyList->getQty($this->item->getProduct()->getId(), $this->item->getId(), $this->item->getQuoteId(), $increaseQty);
}
return $this->quoteItemQtyList->getQty($this->item->getProduct()->getId(), $this->item->getId(), $this->item->getQuoteId(), 0);
}
示例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;
}
示例3: process
/**
* Adds item ID to giftOptionsCartItem configuration and name
*
* @param array $jsLayout
* @param Item $item
* @return array
*/
public function process($jsLayout, Item $item)
{
if (isset($jsLayout['components']['giftOptionsCartItem'])) {
if (!isset($jsLayout['components']['giftOptionsCartItem']['config'])) {
$jsLayout['components']['giftOptionsCartItem']['config'] = [];
}
$jsLayout['components']['giftOptionsCartItem']['config']['itemId'] = $item->getId();
$jsLayout['components']['giftOptionsCartItem-' . $item->getId()] = $jsLayout['components']['giftOptionsCartItem'];
unset($jsLayout['components']['giftOptionsCartItem']);
}
return $jsLayout;
}
示例4: initialize
/**
* Initialize item option
*
* @param \Magento\Quote\Model\Quote\Item\Option $option
* @param \Magento\Quote\Model\Quote\Item $quoteItem
* @param int $qty
*
* @return \Magento\Framework\Object
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function initialize(\Magento\Quote\Model\Quote\Item\Option $option, \Magento\Quote\Model\Quote\Item $quoteItem, $qty)
{
$optionValue = $option->getValue();
$optionQty = $qty * $optionValue;
$increaseOptionQty = ($quoteItem->getQtyToAdd() ? $quoteItem->getQtyToAdd() : $qty) * $optionValue;
$qtyForCheck = $this->quoteItemQtyList->getQty($option->getProduct()->getId(), $quoteItem->getId(), $quoteItem->getQuoteId(), $increaseOptionQty);
$stockItem = $this->getStockItem($option, $quoteItem);
$result = $this->stockState->checkQuoteItemQty($option->getProduct()->getId(), $optionQty, $qtyForCheck, $optionValue, $option->getProduct()->getStore()->getWebsiteId());
if ($result->getItemIsQtyDecimal() !== null) {
$option->setIsQtyDecimal($result->getItemIsQtyDecimal());
}
if ($result->getHasQtyOptionUpdate()) {
$option->setHasQtyOptionUpdate(true);
$quoteItem->updateQtyOption($option, $result->getOrigQty());
$option->setValue($result->getOrigQty());
/**
* if option's qty was updates we also need to update quote item qty
*/
$quoteItem->setData('qty', intval($qty));
}
if ($result->getMessage() !== null) {
$option->setMessage($result->getMessage());
$quoteItem->setMessage($result->getMessage());
}
if ($result->getItemBackorders() !== null) {
$option->setBackorders($result->getItemBackorders());
}
$stockItem->unsIsChildItem();
return $result;
}
示例5: prepare
/**
* Set qty and custom price for quote item
*
* @param Item $item
* @param \Magento\Framework\Object $request
* @param Product $candidate
* @return void
*/
public function prepare(Item $item, Object $request, Product $candidate)
{
/**
* We specify qty after we know about parent (for stock)
*/
if ($request->getResetCount() && !$candidate->getStickWithinParent() && $item->getId() == $request->getId()) {
$item->setData(CartItemInterface::KEY_QTY, 0);
}
$item->addQty($candidate->getCartQty());
$customPrice = $request->getCustomPrice();
if (!empty($customPrice)) {
$item->setCustomPrice($customPrice);
$item->setOriginalCustomPrice($customPrice);
}
}
示例6: getConfigureButtonHtml
/**
* Return html button which calls configure window
*
* @param Item $item
* @return string
*/
public function getConfigureButtonHtml($item)
{
$product = $item->getProduct();
$options = ['label' => __('Configure')];
if ($product->canConfigure()) {
$options['onclick'] = sprintf('order.showQuoteItemConfiguration(%s)', $item->getId());
} else {
$options['class'] = ' disabled';
$options['title'] = __('This product does not have any configurable options');
}
return $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Button')->setData($options)->toHtml();
}
示例7: addItem
/**
* Adding new item to quote
*
* @param \Magento\Quote\Model\Quote\Item $item
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function addItem(\Magento\Quote\Model\Quote\Item $item)
{
$item->setQuote($this);
if (!$item->getId()) {
$this->getItemsCollection()->addItem($item);
$this->_eventManager->dispatch('sales_quote_add_item', ['quote_item' => $item]);
}
return $this;
}
示例8: _removeItem
/**
* Remove item
*
* @param Address $address
* @param AddressItem|Item $item
* @return $this
*/
protected function _removeItem($address, $item)
{
if ($item instanceof Item) {
$address->removeItem($item->getId());
if ($address->getQuote()) {
$address->getQuote()->removeItem($item->getId());
}
} elseif ($item instanceof AddressItem) {
$address->removeItem($item->getId());
if ($address->getQuote()) {
$address->getQuote()->removeItem($item->getQuoteItemId());
}
}
return $this;
}
示例9: setItem
/**
* Set quote item
*
* @param \Magento\Quote\Model\Quote\Item $item
* @return $this
*/
public function setItem($item)
{
$this->setItemId($item->getId());
$this->_item = $item;
return $this;
}
示例10: getDeletePostJson
/**
* Get post parameters for delete from cart
*
* @param \Magento\Quote\Model\Quote\Item $item
* @return string
*/
public function getDeletePostJson($item)
{
$url = $this->_getUrl(self::DELETE_URL);
$data = ['id' => $item->getId()];
if (!$this->_request->isAjax()) {
$data[\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED] = $this->getCurrentBase64Url();
}
return json_encode(['action' => $url, 'data' => $data]);
}