本文整理汇总了PHP中Mage_Sales_Model_Order_Item::getQtyShipped方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Item::getQtyShipped方法的具体用法?PHP Mage_Sales_Model_Order_Item::getQtyShipped怎么用?PHP Mage_Sales_Model_Order_Item::getQtyShipped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Item::getQtyShipped方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQuantityToXml
/**
* Add item quantities to the XML
*
* @param Mage_Core_Block_Template $renderer Product renderer
* @param Mage_XmlConnect_Model_Simplexml_Element $quantityXml
* @param Mage_Sales_Model_Order_Item $item
* @return null
*/
public function addQuantityToXml(Mage_Core_Block_Template $renderer, Mage_XmlConnect_Model_Simplexml_Element $quantityXml, Mage_Sales_Model_Order_Item $item)
{
$qty = 1 * $item->getQtyOrdered();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Ordered')));
}
$qty = 1 * $item->getQtyShipped();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Shipped')));
}
$qty = 1 * $item->getQtyCanceled();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Canceled')));
}
$qty = 1 * $item->getQtyRefunded();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Refunded')));
}
}
示例2: _calculateRefundedQty
/**
* Calculate refund qty
*
* @param Varien_Object $dataObject
* @param Mage_Sales_Model_Order_Item $orderItem
* @return array [not_ship, shipped, total, had_refunded]
*/
protected function _calculateRefundedQty($dataObject, $orderItem)
{
$creditMemo = $dataObject->getCreditmemoObject();
$order = $dataObject->getOrder();
$parentItemId = $orderItem->getParentItemId();
$refundItem = $creditMemo->getItemByOrderId($orderItem->getId());
$parentItem = $parentItemId ? $creditMemo->getItemByOrderId($parentItemId) : false;
if (is_bool($refundItem)) {
$refundQty = $parentItem ? $parentItem->getQty() : 0;
} else {
$refundQty = $parentItem ? $parentItem->getQty() * $refundItem->getQty() : $refundItem->getQty();
}
$oldCreditmemos = $order->getCreditmemosCollection();
/* total refuned qty before created this creditmemo */
$hadRefundedQty = 0;
if (count($oldCreditmemos)) {
foreach ($oldCreditmemos as $oldCreditmemo) {
if ($oldCreditmemo->getId() == $creditMemo->getId()) {
continue;
}
$item = $oldCreditmemo->getItemByOrderId($orderItem->getId());
if ($item) {
$parentItem = $orderItem->getParentItemId() ? $oldCreditmemo->getItemByOrderId($orderItem->getParentItemId()) : false;
$hadRefundedQty += $parentItem ? $parentItem->getQty() * $item->getQty() : $item->getQty();
}
}
}
/* calculate shipped qty */
$shippedQty = $orderItem->getQtyShipped();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$shippedQty = $parentOrderItem->getQtyShipped();
}
}
/* calculate canceled qty */
$canceledQty = $orderItem->getQtyCanceled();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$canceledQty = $parentOrderItem->getQtyCanceled();
}
}
/* total qty which we need to ship before created this credit memo */
$needToShipQty = $orderItem->getQtyOrdered() - $shippedQty - $hadRefundedQty - $canceledQty;
$needToShipQty = $needToShipQty >= 0 ? $needToShipQty : 0;
/* separate refund qty to qty of not_ship items & qty of shipped items */
$refundQtys = array('not_ship' => min($refundQty, $needToShipQty), 'shipped' => $refundQty - min($refundQty, $needToShipQty), 'total' => $refundQty, 'had_refunded' => $hadRefundedQty);
return $refundQtys;
}