本文整理汇总了PHP中Magento\Sales\Model\Order\Item::isDummy方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::isDummy方法的具体用法?PHP Item::isDummy怎么用?PHP Item::isDummy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order\Item
的用法示例。
在下文中一共展示了Item::isDummy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOrderItemVariables
/**
* Retrieve tracking variables for an order item
*
* @param \Magento\Sales\Model\Order\Item $item The order item
*
* @return array
*/
private function getOrderItemVariables($item)
{
$variables = [];
if (!$item->isDummy()) {
$itemId = $item->getId();
$prefix = "order.items.{$itemId}";
$variables[$prefix . '.sku'] = $item->getSku();
$variables[$prefix . '.product_id'] = $item->getProductId();
$variables[$prefix . '.qty'] = $item->getQtyOrdered();
$variables[$prefix . '.price'] = $item->getBasePrice();
$variables[$prefix . '.row_total'] = $item->getRowTotal();
$variables[$prefix . '.label'] = $item->getName();
$variables[$prefix . '.salesrules'] = $item->getAppliedRuleIds();
if ($product = $item->getProduct()) {
$categoriesId = $product->getCategoryIds();
if (count($categoriesId)) {
$variables[$prefix . '.category_ids'] = implode(",", $categoriesId);
}
}
}
return $variables;
}
示例2: canShipItem
/**
* Checks if order item can be shipped.
*
* Dummy item can be shipped or with his children or
* with parent item which is included to shipment.
*
* @param \Magento\Sales\Model\Order\Item $item
* @param array $items
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function canShipItem($item, array $items = [])
{
if ($item->getIsVirtual() || $item->getLockedDoShip()) {
return false;
}
if ($item->isDummy(true)) {
if ($item->getHasChildren()) {
if ($item->isShipSeparately()) {
return true;
}
foreach ($item->getChildrenItems() as $child) {
if ($child->getIsVirtual()) {
continue;
}
if (empty($items)) {
if ($child->getQtyToShip() > 0) {
return true;
}
} else {
if (isset($items[$child->getId()]) && $items[$child->getId()] > 0) {
return true;
}
}
}
return false;
} elseif ($item->getParentItem()) {
$parent = $item->getParentItem();
if (empty($items)) {
return $parent->getQtyToShip() > 0;
} else {
return isset($items[$parent->getId()]) && $items[$parent->getId()] > 0;
}
}
} else {
return $item->getQtyToShip() > 0;
}
}
示例3: _canRefundItem
/**
* Check if order item can be refunded
*
* @param \Magento\Sales\Model\Order\Item $item
* @param array $qtys
* @param array $invoiceQtysRefundLimits
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _canRefundItem($item, $qtys = [], $invoiceQtysRefundLimits = [])
{
if ($item->isDummy()) {
if ($item->getHasChildren()) {
foreach ($item->getChildrenItems() as $child) {
if (empty($qtys)) {
if ($this->_canRefundNoDummyItem($child, $invoiceQtysRefundLimits)) {
return true;
}
} else {
if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) {
return true;
}
}
}
return false;
} elseif ($item->getParentItem()) {
$parent = $item->getParentItem();
if (empty($qtys)) {
return $this->_canRefundNoDummyItem($parent, $invoiceQtysRefundLimits);
} else {
return isset($qtys[$parent->getId()]) && $qtys[$parent->getId()] > 0;
}
}
} else {
return $this->_canRefundNoDummyItem($item, $invoiceQtysRefundLimits);
}
}
示例4: isQtyAvailable
/**
* Checks if quantity available for refund
*
* @param int $qty
* @param \Magento\Sales\Model\Order\Item $orderItem
* @return bool
*/
private function isQtyAvailable($qty, \Magento\Sales\Model\Order\Item $orderItem)
{
return $qty <= $orderItem->getQtyToRefund() || $orderItem->isDummy();
}